Arjun Thakur has Published 1025 Articles

Clearing input buffer in C/C++

Arjun Thakur

Arjun Thakur

Updated on 28-Apr-2025 15:39:01

26K+ Views

In C/C++, an input buffer is a temporary storage area where the program processes the input. Suppose, you are an user and you type some characters using a keyboard but those characters are not passed to the program directly because it involves several layers of handling such as keyboard firmware, ... Read More

How to group Python tuple elements by their first element?

Arjun Thakur

Arjun Thakur

Updated on 15-Apr-2025 18:16:45

751 Views

A tuple is an ordered, immutable sequence of elements. In Python, the grouping of elements in a tuple list based on the values of their second elements can be done using various methods like using a dictionary or using itertools.groupby() method and using defaultdict from collections. Grouping the first ... Read More

Java Program to set the extent in JSlider

Arjun Thakur

Arjun Thakur

Updated on 02-Jan-2025 19:12:54

269 Views

In this article, we will learn how to set the extent of a JSlider using Java Swing. The extent defines the size of the range that the slider's knob can move within, restricting its movement past a certain point. JSlider JSlider is a component in Java Swing that provides ... Read More

Java program to find largest of the three numbers using ternary operators

Arjun Thakur

Arjun Thakur

Updated on 11-Dec-2024 19:33:48

1K+ Views

In this article, we’ll learn to find the largest of three numbers using the ternary operator in Java. This simple yet effective approach allows you to write concise and readable code. Finding the largest of three numbers is a common programming task, and Java provides an efficient way to do ... Read More

Java string toUpperCase() method example

Arjun Thakur

Arjun Thakur

Updated on 07-Nov-2024 17:48:23

128 Views

In this article, we will learn how to convert all characters in a string to uppercase using the toUpperCase() method in Java. This method has two versions: one that uses the system's default language settings and another that lets you choose a specific language. Changing string characters to uppercase helps keep ... Read More

Java program to swap two numbers using XOR operator

Arjun Thakur

Arjun Thakur

Updated on 05-Nov-2024 22:02:32

622 Views

In this article, we will learn how to swap two numbers using the XOR bitwise operator in Java. The XOR operator is a powerful tool that allows you to perform bitwise operations, and one of its interesting properties is that it can be used to swap two variables without using ... Read More

Java program to select a column in JTable

Arjun Thakur

Arjun Thakur

Updated on 25-Oct-2024 23:40:18

1K+ Views

In this article, we will learn how to select a specific column in a JTable using Java’s Swing library. The program creates a simple table displaying a list of products along with their quantities. We use setColumnSelectionInterval() to highlight a single column based on an interval, so in this example, ... Read More

Java program to fill elements in a char array

Arjun Thakur

Arjun Thakur

Updated on 18-Oct-2024 11:56:59

983 Views

In this article, we will fill elements in a char array using Java. We will be using the Arrays.fill() method to fill it with a specific character. This method allows us to assign a single character value to all elements in the array. We will fill the array with the character ... Read More

Java program without making class

Arjun Thakur

Arjun Thakur

Updated on 16-Oct-2024 16:29:26

1K+ Views

Is it possible to create and run a Java program without any class? The answer is Yes. The trick is to use an enum instead of a Class.Enums are similar to classes, but instead of using the class keyword, we use enum to define them. An enum is used to represent a ... Read More

Java program to join two given lists

Arjun Thakur

Arjun Thakur

Updated on 14-Aug-2024 22:21:48

3K+ Views

To join two given lists the addAll() method of the java.util.ArrayList class is used to insert all of the elements in the specified collection into this list. To add contents of a list to another − Problem Statement Write a program in Java to join two given lists − Input ... Read More

1 2 3 4 5 ... 103 Next
Advertisements