
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 7442 Articles for Java

195 Views
In this article, we will learn about the new methods added to the Process API in Java 9. First, we will know about what is process API, and the methods in Process API in detail. What is Process API? In Java, the Process API, we can perform any operation regarding a process. If one must get the process ID of currently running process, or to create a new process, or destroy an already running one, or find child and parent processes of currently running process, or just get any information about a process, then the Process API is used to perform ... Read More

570 Views
In Java 9, an interface can also have private methods. Apart from static and default methods in Java 8, this is another significant change as it allows the re-usability of common code within the interface itself.In an interface, there is a possibility of writing common code on more than one default method that leads to code duplication. The introduction of private methods avoids this code duplication.Advantages of private methods in an interfaceAvoiding code duplication.Ensuring code re-usability.Improving code readability.Syntaxinterface interfacename { private methodName(parameters) { // statements } }Exampleinterface Test { default void m1() { common(); } ... Read More

430 Views
In Java 8, the iterate() method of Stream API takes the seed and the unary operator as arguments. As stream becomes infinite, it makes the developer add explicit termination conditions by using limit, findFirst, findAny and etc. In Java 9, the iterate() method of Stream API has added a new argument, a predicate that takes the condition to break the flow.Syntaxstatic Stream iterate(T seed, Predicate

435 Views
In Java 9, several factory methods have added to Collections API. By using these factory methods, we can create unmodifiable list, set and map collection objects to reduce the number of lines of code. The List.of(), Set.of(), Map.of() and Map.ofEntries() are the static factory methods that provide convenient way of creating immutable collections in Java 9.Benefits of Immutable CollectionsLess heap space: The space required to store a collection data is very less as compared with the traditional approach in earlier versions of java.Faster access to data: As the overhead to store data and wrap into Collections.unmodifiable is reduced, now data access becomes faster. It means that ... Read More

2K+ Views
In this article, we will learn about the differences between the orTimeout() and the completeOnTimeout() methods in Java. Both the orTimeout() and completeOnTimeout() methods are defined in the CompletableFuture class, and these two methods were introduced in Java 9. CompletableFuture class The CompletableFuture class, introduced in Java 8, represents a Future that can have its value and status set explicitly. It also supports dependent functions and actions that are triggered upon the completion of the future. In Java 9, the CompletableFuture API received further enhancements. The following are some common methods of the CompletableFuture class: ... Read More

2K+ Views
In this article, we will learn to use the ofNullable() method of Stream in Java 9. We will first go through the Stream class, after that we will learn about the ofNullable() method along with its syntax and real-world use cases. Stream Class Stream was introduced in Java 8, the Stream API is used to process collections of objects. It represents a sequence of elements that support various operations to perform computations in parallel. Creating an instance of a stream: Stream stream; A stream is not a type of data structure, it takes input from Collections, Arrays, etc. The ofNullable() ... Read More

434 Views
In this article, we will learn to create an unmodifiable Map in Java 9. First, we will learn about Map and Unmodifiable Map and after that we will be knowing the different ways through which we can create an unmodifiable map (Map.of method and unmodifiableMap() Method). Map In Java, a Map is an interface in the Collections framework used to store data in the form of key-value pairs. Each key in the map is unique and maps to some value. Some of the implementations of the Map interface are: HashMap ... Read More

255 Views
In this article, we will learn about the new methods that have been added to the Arrays class in Java 9. First, we will learn about arrays, and then the new methods added to the equals(), compare(), and mismatch() methods with examples. Arrays Java provides a data structure called the Array, and they are used to store multiple values of the same datatype in a single variable. The Arrays class can contain various methods for manipulating arrays and also contains static factory methods that allow arrays to view as a list. Creating an instance of an Array with a variable ... Read More

239 Views
In this article, we will learn to create an unmodifiable Set in Java 9. We will be learning about Set and unmodifiable Set, and will be learning different ways of creating an unmodifiable Set(Set.of() Method and unmodifiableSet() Method). Set In Java, a Set is an interface that inherits the Collection interface and contains no duplicate elements. A Set interface has methods to add, delete, and check the existence of an element. Some of the implementations of the Set interface are: HashSet TreeSet LinkedHashSet What is an ... Read More

1K+ Views
Java 9 provides factory methods to create immutable lists, sets, and maps. It can be useful to create empty or non-empty collection objects. In Java 8 and earlier versions, we can use collection class utility methods like unmodifiableXXX to create immutable collection objects. If we need to create an immutable list, then use the Collections.unmodifiableList() method. What does Immutable mean? An object is considered immutable if its state cannot change after it is constructed. Any modification creates a new object instead. String name = "TutorialsPoint"; name = name + "10"; Here, "TutorialsPoint" is an immutable string, and we cannot modify it directly. Instead, we use the ... Read More