Java Articles

Page 60 of 450

StringJoiner merge() method in Java 8

Krantik Chavan
Krantik Chavan
Updated on 11-Mar-2026 373 Views

The merge() method of the StringJoiner class in Java 8 is used to merge the contents of the StringJoiner str, which is passed as a parameter. The content gets added as the next element.The syntax is as follows:public StringJoiner merge(StringJoiner str)Here, str is the StringJoiner content to be merged.To work with the StringJoiner in Java 8, import the following package:import java.util.StringJoiner;The following is an example to implement StringJoiner merge() method in Java:Exampleimport java.util.StringJoiner; public class Demo {    public static void main(String[] args) {       // StringJoiner 1       StringJoiner strJoin1 = new StringJoiner(" ");   ...

Read More

The size() method of Java AbstractCollection class

Daniol Thomas
Daniol Thomas
Updated on 11-Mar-2026 248 Views

The size() method of the AbstractCollection class returns the numbers of elements in the collection. The method returns Integer.MAX_VALUE if the total number of elemnts in the collection exceeds the Interger.MAX_VALUE.The syntax is as follows:public abstract int size()To work with AbstractCollection class in Java, import the following package:import java.util.AbstractCollection;The following is an example to implement AbstractCollection size() method in Java:Exampleimport java.util.ArrayList; import java.util.AbstractCollection; public class Demo {    public static void main(String[] args) {       AbstractCollection absCollection = new ArrayList();       absCollection.add("Laptop");       absCollection.add("Tablet");       absCollection.add("Mobile");       absCollection.add("E-Book Reader");   ...

Read More

The addAll() method of Java AbstractSequentialList class

Daniol Thomas
Daniol Thomas
Updated on 11-Mar-2026 164 Views

The addAll() method of the AbstractSequentialList class inserts all the elements in the specified collection into this list at the specified position. Set the specified position as the parameter.The syntax is as follows:boolean addAll(int index, Collection

Read More

DoubleStream empty() method in Java

Krantik Chavan
Krantik Chavan
Updated on 11-Mar-2026 124 Views

The empty() method of the DoubleStream class in Java returns an empty sequential DoubleStream.The syntax is as follows:static DoubleStream empty()To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Let us create an empty DoubleStream:DoubleStream doubleStream = DoubleStream.empty();Now, let us check the number of elements in the stream. It will be 0, since the stream is set to empty:doubleStream.count()The following is an example to implement DoubleStream empty() method in Java:Exampleimport java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream = DoubleStream.empty();       System.out.println("Number of elements in the stream = ...

Read More

The containsAll() method of AbstractSequentialList in Java

Nancy Den
Nancy Den
Updated on 11-Mar-2026 174 Views

The containsAll() method of the AbstractSequentialList checks for all the elements in this collection. It returns TRUE if all this collection contains all the elements in the specified collection i.e. if the two collections are same.The syntax is as follows:public boolean containsAll(Collection c)Here, c is the collection to be checkedTo work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList containsAll() method in Java:Exampleimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       AbstractSequentialList absSequential = new LinkedList();     ...

Read More

What is AbstractList Class in Java?

Nancy Den
Nancy Den
Updated on 11-Mar-2026 858 Views

The AbstractList class provides an implementation of the List interface.For an unmodifiable listProgrammer needs to extend this class and provide implementations for the get(int) and size() methods.For a modifiable listProgrammer must override the set(int, E) method. If the list is variable-size the programmer must override the add(int, E) and remove(int) methods.The following is the syntax:public abstract class AbstractList extends AbstractCollection implements ListTo work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement AbstractList class:Exampleimport java.util.LinkedList; import java.util.AbstractList; public class Demo {    public static void main(String[] args) {       AbstractList myList = ...

Read More

How to add elements to AbstractList class in Java?

Nancy Den
Nancy Den
Updated on 11-Mar-2026 491 Views

To add elements to AbstractList class, the add() method is provided by the AbstractList class. The elemnt gets appended at the end of the list.The syntax is as follows:public boolean add(E ele)Here, the parameter ele is an element to be appended to this listTo work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to add elements to AbstractlList class in Java:Exampleimport java.util.LinkedList; import java.util.AbstractList; public class Demo {    public static void main(String[] args) {       AbstractList myList = new LinkedList();       myList.add(50);       myList.add(100);       myList.add(150); ...

Read More

The set() method of AbstractList class in Java

Daniol Thomas
Daniol Thomas
Updated on 11-Mar-2026 150 Views

The set() method of the AbstractList class is used to replace the element at the specified position in this list with the specified element. It returns the element that gets replaced.The syntax is as follows:public E set(int index, E ele)Here, the parameter index is the index of the element to replace, whereas ele is the element to be stored at the specified position.To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement set() method of the AbstractlList class in Java:Exampleimport java.util.LinkedList; import java.util.AbstractList; public class Demo {    public static void main(String[] args) ...

Read More

The contains() method of Java AbstractCollection class

Daniol Thomas
Daniol Thomas
Updated on 11-Mar-2026 186 Views

The contains() method of the AbstractCollection class checks whether an element is in the AbstractCollection or not. It returns a Boolean i.e. TRUE if the element is in the collection, else FALSE is returned.The syntax is as follows:public boolean contains(Object ele)Here, ele is the element to be checked for existence.To work with AbstractCollection class in Java, import the following package:import java.util.AbstractCollection;The following is an example to implement AbstractCollection contains() method in Java:Exampleimport java.util.ArrayList; import java.util.AbstractCollection; public class Demo {    public static void main(String[] args) {       AbstractCollection absCollection = new ArrayList();       absCollection.add("Football");     ...

Read More

The remove() method of AbstractList class in Java

Daniol Thomas
Daniol Thomas
Updated on 11-Mar-2026 375 Views

Remove an element at a specified position from the list using the remove() method. The position is to be set as index parameter in the method itself. It returns the element which is removed.The syntax is as follows:public E remove(int index)Here, index is the index from where you want to delete the element.To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement remove() method of the AbstractlList class in Java:Exampleimport java.util.ArrayList; import java.util.AbstractList; public class Demo {    public static void main(String[] args) {       AbstractList myList = new ArrayList();   ...

Read More
Showing 591–600 of 4,498 articles
« Prev 1 58 59 60 61 62 450 Next »
Advertisements