Arjun Thakur has Published 1085 Articles

Clearing input buffer in C/C++

Arjun Thakur

Arjun Thakur

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

25K+ 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

641 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

2D vector in C++ with user defined size

Arjun Thakur

Arjun Thakur

Updated on 14-Feb-2025 18:08:22

3K+ Views

In C++, a vector is a dynamic array used to store elements. A 2D vector is a vector of vectors, which is useful for things like matrices or grids. In this tutorial, we'll show you how to create and use 2D vectors with a size you choose. A 2D ... Read More

Java Program to set the extent in JSlider

Arjun Thakur

Arjun Thakur

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

211 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

872 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

What is the lifetime of a static variable in a C++ function?

Arjun Thakur

Arjun Thakur

Updated on 02-Dec-2024 00:25:40

17K+ Views

A static variable is a variable that is declared using the keyword static. The space for the static variable is allocated only one time and this is used for the entirety of the program. Once this variable is declared, it exists till the program executes. So, the lifetime of a ... Read More

Java string toUpperCase() method example

Arjun Thakur

Arjun Thakur

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

99 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

506 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

882 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

1 2 3 4 5 ... 109 Next
Advertisements