Vivek Verma has Published 31 Articles

How to get Sublist of an ArrayList using Java?

Vivek Verma

Vivek Verma

Updated on 21-May-2025 16:49:38

2K+ Views

In Java, an ArrayList is a class of the List interface, which stores elements of similar data types and can be null while creating. A sub-list is the view of a portion (or part) of an ArrayList. For example, if the given array list is {1, 2, 3, 4, 5}, then the possible sub-lists ... Read More

How to remove element from ArrayList in Java?

Vivek Verma

Vivek Verma

Updated on 20-May-2025 16:16:58

532 Views

The article will discuss different ways to remove elements from an ArrayList. Below is a list of methods that can help in removing elements from an ArrayList: Using the remove() Method of List Interface Using the remove(object) Method ... Read More

How to check if ArrayList contains an item in Java?

Vivek Verma

Vivek Verma

Updated on 19-May-2025 15:27:41

4K+ Views

To check if an ArrayList contains a specific item, we can either compare each element with the given item and print the result if they are equal, or use a predefined method that directly checks for the containing element. ArrayList in Java In Java, an ArrayList is a class similar ... Read More

How to get the first element of the List in Java?

Vivek Verma

Vivek Verma

Updated on 19-May-2025 14:44:54

21K+ Views

A list stores a sequence of elements of a similar type. Like an array, the elements in a List are stored at specific indices, starting from index 0. The 0th index indicates the "first element", the 1st indicates the "second" element, and so on. In Java, a list is represented ... Read More

How to find an element in a List with Java?

Vivek Verma

Vivek Verma

Updated on 16-May-2025 19:20:46

23K+ Views

In Java, a List is an interface that extends the Collection interface and represents a sequence of elements. Since the List is an interface. To create a List object, we need to instantiate a class that implements the List interface, such as ArrayList.  The List provides various methods that ... Read More

Importance of XOR operator in Java?

Vivek Verma

Vivek Verma

Updated on 14-May-2025 19:35:13

11K+ Views

Bitwise XOR (exclusive or) "^" is an operator in Java that provides the answer '1' if both of the bits in its operands are different; if both of the bits are the same, then the XOR operator gives the result '0'. XOR is a binary operator that is evaluated from ... Read More

Will a finally block execute after a return statement in a method in Java?

Vivek Verma

Vivek Verma

Updated on 14-May-2025 19:25:38

20K+ Views

Yes, the finally block will be executed even after a return statement within a try or catch block in a Java method. Finally Block after the Return Statement Usually, the return statement will be the last in a Java method. If you try to add any statements after the return ... Read More

How to convert an OutputStream to a Writer in Java?

Vivek Verma

Vivek Verma

Updated on 14-May-2025 19:09:21

2K+ Views

Input and output Streams in Java are objects that accepts sequence of information and sends them further. These are used to read and write data from/to various sources.What are Output Streams & WritersA Java output streams accept output data (bytes) from a source and sends it to the destination. An ... Read More

How to find the unicode category for a given character in Java?

Vivek Verma

Vivek Verma

Updated on 14-May-2025 14:12:22

5K+ Views

A Character class is a subclass of the class named Object, and it wraps a value of the primitive type char. An object of type Character contains a single field whose type is char. Unicode Category of a Character In Java, the Unicode category of a character refers to the ... Read More

How can we avoid a deadlock in Java?

Vivek Verma

Vivek Verma

Updated on 14-May-2025 14:07:06

5K+ Views

This article explains several strategies to avoid deadlock in Java, including a brief introduction to deadlock, strategies, and respective examples. Deadlock in Java In case of multi-threading, a deadlock is a programming situation where two or more threads are holding resources needed by other threads and are blocked forever, waiting ... Read More