- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34472 Articles for Programming
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
3K+ Views
To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any node, which is not visited, then the graph is not connected.For the undirected graph, we will select one node and traverse from it.In this case the traversal algorithm is recursive DFS traversal.Input − Adjacency matrix of a graph0110010110110110110100110Output − The Graph is connected.Algorithmtraverse(u, visited)Input − The start node u and the visited node to mark which node is visited.Output: Traverse all connected vertices.Begin mark u as visited for all ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
77 Views
The AbstractSequentialList class has the add() method to add an element to the specific position.The syntax is as followsadd(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 packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList add() method in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList absSequential = new LinkedList(); absSequential.add(0, 50); absSequential.add(1, 30); ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
126 Views
The syntax is as followsDoubleStream peek(DoubleConsumer action)Here, DoubleConsumer is an operation that accepts a single double-valued argument and returns no result.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;The following is an example to implement DoubleStream peek() method in JavaExample Live Demoimport java.util.*; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream = DoubleStream.of(28.7, 35.6, 48.3, 69.8, 75.8, 80.5, 90.8); System.out.println("Elements in the stream..."); long num = doubleStream.peek(System.out::println).count(); System.out.println("Number of elements in the stream = " + num); } ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
72 Views
The lastIndexOf() method returns the index of the last occurrence of the specified element in this list. It returns -1 if this list does not contain the element.The syntax is as followspublic int lastIndexOf(Object ob)Here, ob is the element. The return value would be the last index of this element.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 lastIndexOf() method in JavaExample Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo { public static void main(String[] args) { CopyOnWriteArrayList arrList = new CopyOnWriteArrayList(); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
71 Views
The iterator() method is used to return an iterator over the elements in this list.The syntax is as followsIterator iterator()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 iterator() method in JavaExample Live Demoimport java.util.Arrays; import java.util.Iterator; import java.util.concurrent.CopyOnWriteArrayList; public class Demo { public static void main(String[] args) { CopyOnWriteArrayList arrList = new CopyOnWriteArrayList(); arrList.add(50); arrList.add(90); arrList.add(150); arrList.add(200); arrList.add(350); arrList.add(500); arrList.add(650); ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
65 Views
A KeyValue class is a Tuple of 2 elements i.e. a key and value. It is in the JavaTuples library. The following is the declaration −public final class KeyValue extends Tuple implements IValueKey, IValueValueLet us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package −import org.javatuples.KeyValue;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
121 Views
To iterate through the LabelValue tuple value, use a simple for loop just like what we do in other collections. Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package −import org.javatuples.LabelValue;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −Steps − How to run JavaTuples ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
51 Views
Use the contains() method of the LabelValue class in Java to search for a value. The return value of the method is TRUE if the value exists in the tuple, else the FALSE value is returned.Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package−import org.javatuples.LabelValue;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
73 Views
The accept() method of the DoubleStream class in Java adds an element to the stream being built.The syntax is as follows −void accept(double ele)Here, ele is the element to be inserted into the stream.To use the DoubleStream.Builder class in Java, import the following package −import java.util.stream.DoubleStream;The following is an example to implement DoubleStream.Builder() accept() method in Java −Example Live Demoimport java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream.Builder builder = DoubleStream.builder(); builder.accept(12.9); builder.accept(25.6); builder.accept(35.8); builder.accept(43.9); builder.accept(56.3); ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
69 Views
The builder() method of the DoubleStream class returns a builder for a DoubleStream.The syntax is as follows −static DoubleStream.Builder builder()To use the DoubleStream class in Java, import the following package −import java.util.stream.DoubleStream;The following is an example to implement DoubleStream builder() method in Java −Example Live Demoimport java.util.stream.Stream; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream = DoubleStream.builder().add(15.9).build(); doubleStream.forEach(System.out::println); } }Output15.9