
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 9150 Articles for Object Oriented Programming

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

436 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

519 Views
In this article, we will learn about useful commands in JShell. Java 9 has introduced a new interactive tool called JShell. This tool can be used to execute, test user-friendly and easy way of Java classes, interfaces, enums, objects, statements and etc. Different Useful Commands in JShell Below are some of the important commands in JShell: /open /var /types /methods /list /help /open To execute a script after JShell has started, we will use ... Read More

399 Views
JShell is a new java shell tool released in java 9. It is the first official REPL (Read-Evaluate-Print-Loop) application. This tool helps in executing and evaluating simple java programs and logics such as statements, loops, expressions, and etc. Java REPL provides a simple programming environment in the command prompt. It can read the input, evaluate it and print the output.In the below example we can able to create a class and object in JShell using command prompt.Examplejshell> class Employee { ...> private String name; ...> Employee(String name) { ...> this.name=name; ...> } ...> ... Read More

756 Views
StackWalker API allows easy filtering and lazy access to execute tasks within any method. It is an efficient API for obtaining stack trace information in Java 9.There are three new important classes in StackWalker API: StackWalker, StackWalker.StackFrame and StackWalker.Option.StackWalker − It is the main class in StackWalker API. We traverse stack frames by using StackWalker.forEach() method and get caller class in an efficient way by calling StackWalker.getCallerClass() method. We walk through stack traces and applying a function on a stream of stack frames by using StackWalker.walk() method.StackWalker.StackFrame − It is a static nested class of StackWalker and represents method invocation return by StackWalker. It has methods ... Read More