Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 2 of 81

IntStream peek() method in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 771 Views

The peek() method in the IntStream class in Java returns a stream consisting of the elements of this stream. It additionally performs the provided action on each element as elements are consumed from the resulting stream.The syntax is as followsIntStream peek(IntConsumer action)Here, the parameter action is a non-interfering action to perform on the elements as they are consumed from the stream. The IntConsumer represents an operation that accepts a single int-valued argument and returns no result.The following is an example to implement IntStream peek() method in JavaExampleimport java.util.*; import java.util.stream.IntStream; public class Demo { public static void ...

Read More

IntStream forEachOrdered() method in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 433 Views

The forEachOrdered() method in Java assures that each element is processed in order for streams that have a defined encounter order.The syntax is as followsvoid forEachOrdered(IntConsumer action)Here, the action parameter is a non-interfering action to be performed on the elements.Create an IntStream and add elements to the streamIntStream intStream = IntStream.of(50, 70, 80, 100, 130, 150, 200);Now, use the forEachOrdered() method to display the stream elements in orderintStream.forEachOrdered(System.out::println);The following is an example to implement IntStream forEachOrdered() method in JavaExampleimport java.util.*; import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { ...

Read More

The toArray(T[] a) method of CopyOnWriteArrayList in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 148 Views

The difference between toArray() and toArray(T[] arr) of the CopyOnWriteArrayList class is that both the methods returns an array containing all of the elements in this collection, but the latter has some additional features i.e. the runtime type of the returned array is that of the specified array.The syntax is as followspublic T[] toArray(T[] arr)Here, the parameter arr is the array into which the elements of the list are to be stored.To work with CopyOnWriteArrayList class, you need to import the following packageimport java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class toArray() method in JavaExampleimport java.util.Arrays; import java.util.concurrent.CopyOnWriteArrayList; ...

Read More

ArrayBlockingQueue drainTo() Method in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 270 Views

The drainTo() method of the ArrayBlockingQueue class removes all available elements from this queue and adds them to the given collection. It returns the number of elements transferred.The syntax is as followsint drainTo(Collection

Read More

HTML <area> alt Attribute

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 331 Views

The alt attribute of element is used to set an alternate text for an area. This alternate text i.e. alt is visible when the image isn’t displayed for reasons like internet, loading issues, errors, etc.Following is the syntax −Here, text is the alt text to be set.Let us now see an example to implement the alt attribute of the element −Example Learning Learn these technologies with ease.... OutputIn the above example, we have set the map on the following image ...

Read More

HTML <area> download Attribute

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 217 Views

The download attribute of the element is used to set the name of the file to be downloaded which would download when user clicks on the hyperlink.Following is the syntax −The file is the name of the file set for download.Let us now see an example to implement the download attribute of the element −Example Learning Learn these technologies with ease.... OutputNow, when you will click on let’s say “PERL”, the file will download as shown below −Above, we have ...

Read More

IntStream findFirst() method in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 470 Views

The findFirst() method in Java returns an OptionalInt describing the first element of this stream. If the stream is empty, an empty OptionalInt is returned.The syntax is as followsOptionalInt findFirst()Here, OptionalInt is a container object which may or may not contain an int value.To work with the IntStream class in Java, import the following packageimport java.util.stream.IntStream;For OptionalInt class, import the following packageimport java.util.OptionalInt;First, create an IntStream and add elementsIntStream intStream = IntStream.of(30, 45, 70, 80, 90, 120);Now, get the first element of this streamOptionalInt res = intStream.findFirst();The following is an example to implement IntStream findFirst() method in JavaExampleimport java.util.OptionalInt; import ...

Read More

IntStream map() method in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 3K+ Views

The IntStream map() method returns the new stream consisting of the results of applying the given function to the elements of this stream.The syntax is as followsIntStream map(IntUnaryOperator mapper)Here, mapper parameter is a non-interfering, stateless function to apply to each elementCreate an IntStream and add some elementsIntStream intStream1 = IntStream.of(20, 35, 40, 55, 60);Now, map it with the new IntStream and display the updated stream elements applying the condition in the map() functionIntStream intStream2 = intStream1.map(a -> (a + a));The following is an example to implement IntStream map() method in JavaExampleimport java.util.*; import java.util.stream.IntStream; public class Demo {    public ...

Read More

HTML <output> for Attribute

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 157 Views

The for attribute of the element sets the relationship between the result of the calculation and the elements used in the calculation.Following is the syntax:Above, id is the element id, which sets a separate list of one or more elements with a space. These elements specify the relationship between the result of the calculation and the elements used in the calculation.Let us now see an example to implement the for attribute of the element:Example Result 0    100++    = OutputNow, increase the slider and the result would get displayed:

Read More

Insert the specified element at the specified position in Java CopyOnWriteArrayList

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 161 Views

Using the add() method, insert the specified element at the specified position in the CopyOnWriteArrayList.The syntax is as followsvoid add(int index, E ele)Here, the parameter index is where you want to insert the element and ele is the element to be inserted to this list. To work with CopyOnWriteArrayList class, you need to import the following packageimport java.util.concurrent.CopyOnWriteArrayList;The following is an example to add elements in the CopyOnWriteArrayList class in JavaExampleimport java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] args) {       CopyOnWriteArrayList arrList = new CopyOnWriteArrayList();       arrList.add(100);       arrList.add(250);   ...

Read More
Showing 11–20 of 810 articles
« Prev 1 2 3 4 5 81 Next »
Advertisements