Nancy Den

Nancy Den

179 Articles Published

Articles by Nancy Den

Page 7 of 18

Bootstrap btn-group-vertical class

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

The btn-group-vertical class make a set of buttons appear vertically stacked rather than horizontally.You can try to run the following code to implement btn-group-vertical class:Example           Bootstrap Example                                          BCA          B.Tech                                      Masters                                                        MCA                MBA                M.Tech                M.COM                                

Read More

LocalDate until() Method in Java

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

The difference between two LocalDate objects can be obtained using the until() method in the LocalDate class in Java. This method requires a single parameter i.e. the end date for the LocalDate object and it returns the difference between two LocalDate objects using a Period object.A program that demonstrates this is given as follows:Exampleimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDate ld1 = LocalDate.parse("2019-01-10");       LocalDate ld2 = LocalDate.parse("2019-02-14");       System.out.println("The first LocalDate is: " + ld1);       System.out.println("The second LocalDate is: " + ld2); ...

Read More

The add() method of Java AbstractSequentialList class

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

The AbstractSequentialList class has the add(int index, E ele) method to add element to the specific position. You can also use the add() method inherited from AbstractList class.add(int index, E ele) methodThe syntax is as follows:add(int index, E ele)Here, index is where the element is to be inserted. The ele is the element to be inserted.To 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 add() method in Java:Exampleimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       AbstractSequentialList ...

Read More

The clear() method of CopyOnWriteArrayListin Java

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

To remove all the elements from the CopyOnWriteArrayList, use the clear() method. It empties the list.The syntax is as follows:void clear()To work with CopyOnWriteArrayList class, you need to import the following package:import java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class clear() method in Java:Exampleimport java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] args) {       CopyOnWriteArrayList arrList = new CopyOnWriteArrayList();       arrList.add(220);       arrList.add(250);       arrList.add(400);       arrList.add(500);       arrList.add(650);       arrList.add(700);       arrList.add(800);       System.out.println("CopyOnWriteArrayList String Representation = ...

Read More

LongStream range() method in Java

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

The range() method of the LongStream class in Java returns a sequential ordered LongStream from startInclusive to endExclusive by an incremental step of 1. This is inclusive of the initial element and exclusive of the last element.The syntax is as follows:static LongStream range(long startInclusive, long endExclusive)Here, startInclusive is the first value, whereas the endExclusive is the last.To use the LongStream class in Java, import the following package:import java.util.stream.LongStream;The following is an example to implement LongStream range() method in Java:Exampleimport java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream longStream = LongStream.range(20L, 25L);   ...

Read More

What is StringJoiner class in Java 8?

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

The StringJoiner class in Java 8 constructs a sequence of characters. This sequence is separated by a delimiter and optionally starting with a supplied prefix and ending with a supplied suffix.The following are the constructors of the StringJoiner class:StringJoiner(CharSequence delimiter): This constructor constructs a StringJoiner with no characters in it and with no prefix or suffix. It used the copy of the supplied delimiter.StringJoiner(CharSequence delimiter, CharSequence prefix, CharSequence suffix) This constructor constructs a StringJoiner with no characters in it. It uses the copies of the supplied prefix, delimiter and suffix.The syntax is as follows:public final class StringJoiner extends ObjectHere, class ...

Read More

The add() method in Java Stream.Builder

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

Use the add() method to insert elements in the Stream.Builder. The element to be added is a parameter for the add().The following is the syntax:default Stream.Builder add(T t)Here, t is the element to be added.Import the following package for the Stream.Builder class in Java:import java.util.stream.Stream;At first, create Stream.Builder:Stream.Builder builder = Stream.builder();Now, add elements using add() method:builder.add("This"); builder.add("is"); builder.add("it!");Here is an example displaying how to implement add() method of Stream.Builder in Java:Exampleimport java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       Stream.Builder builder = Stream.builder();       builder.add("This");       builder.add("is");     ...

Read More

The accept() method in Java Stream.Builder

Nancy Den
Nancy Den
Updated on 11-Mar-2026 2K+ Views

Add an element to the stream using the accept() method of Java Stream.Builder.The following is the syntax:void accept(T t)Here, t is the argument to be inserted.Import the following package for the Stream.Builder class in Java:import java.util.stream.Stream;First, declare a Stream.Builder:Stream.Builder builder = Stream.builder();Now, use the accept() method:builder.accept("Demo"); builder.accept("Text");The following is an example displaying how to implement accept() method of Stream.Builder in Java:Exampleimport java.util.stream.Stream; public class Demo {    public static void main(String[] args){       Stream.Builder builder = Stream.builder();       builder.accept("Demo");       builder.accept("Text");       Stream str = builder.build();       str.forEach(System.out::println);    } ...

Read More

Convert Character Array to IntStream in Java

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

Let’s say the following is our character array:Character arr[] = { 'V', 'e', 'h', 'i', 'c', 'l' , 'e' };To convert the above character array to IntStreamIntStream stream = Stream.of(arr).flatMapToInt(IntStream::of);We have used the flatMapToInt() method for this.The following is an example to convert character array to IntStream in Java:Exampleimport java.util.stream.*; public class Main {    public static void main(String[] args) {       Character arr[] = { 'V', 'e', 'h', 'i', 'c', 'l' , 'e' };       System.out.println("The character array = ");       for (char value : arr) {          System.out.println("Value = ...

Read More

Convert String to IntStream in Java

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

If you have a string and you want to convert it into IntStream with ASCII values, then it can be easily achieved using the below code.To work with IntStream class, you need to import the following package:import java.util.stream.IntStream;Let’s say the following is our string:String str = "Benz";Convert the above string to IntStream:IntStream stream = str.chars();The following is an example to convert String to IntStream in Java:Exampleimport java.util.stream.IntStream; public class Demo {    public static void main(String[] args) {       String str = "Benz";       System.out.println("String to be converted = " + str);       System.out.println("String ...

Read More
Showing 61–70 of 179 articles
« Prev 1 5 6 7 8 9 18 Next »
Advertisements