- 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 2616 Articles for Java
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
292 Views
In Java 9, a new method added to the Collectors class: flatMapping(). It is similar to the Collectors.mapping() method in which the flatMapping() method allows us to handle nested collections. The Collectors.flatMapping() method takes a function to be applied to input elements and a collector to accumulate the elements passed through the function. Unlike the Collectors.mapping() method, the Collectors.flatMapping() method deals with a stream of elements that allows us to get rid of unnecessary intermediary collections.Syntaxpublic static Collector flatMapping(Function
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
283 Views
Collectors class is an essential part of the Stream API. In Java 9, a new method: filtering() added to the Collectors class. The Collectors.filtering() method can be used for filtering elements in a stream. It is similar to the filter() method on streams. The filter() method processes the values before they have grouped whereas the filtering() method can be used nicely with the Collectors.groupingBy() method to group the values before the filtering step takes place.Syntaxpublic static Collector filtering(Predicate
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
221 Views
JShell is a command-line tool that allows us to enter Java statements (simple statements, compound statements, or even full methods and classes), evaluates it and prints the result.Forward references are commands that refer to methods, variables, or classes that don't exist in any code we have typed in JShell. As code entered and evaluated sequentially in JShell, these forward references have temporarily unresolved. JShell supports forward references in method bodies, return types, parameter types, variable types, and within a class.In the below code snippet, created a method forwardReference() in Jshell. This method can't be invoked until the variable is declared. If we are trying to attempt to call this method, it throws a ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
326 Views
JShell is an interactive tool introduced since Java 9. It is Java's first official REPL tool to create a simple programming environment in the command-line that reads the user's inputs, evaluates it, and prints the result.We can able to create a new JShell instance programmatically in Java language. JShell and its associated APIs can be found under jdk.jshell package. we can get a new instance for JShell by using the static method: create() of JShell class. The eval() method of JShell class used to add an expression to JShell instance. It returns a list of events triggered by the evaluation. It is exactly one ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
353 Views
JShell is an interactive tool that allows us to execute the java code and getting immediate results. We quickly evaluate expressions or short algorithms without compiling or build it. We can execute expressions, classes, methods, variables, and etc with the help of the JShell tool.Below are some of the keyboard shortcut keys:Entrance - Validate the lineLeft arrow - Move left in the lineRight arrow - Move right in the lineCtrl-A - Move to the start of the lineCtrl-E- Move to the end of the lineAlt-B - Move left, word by wordAlt-F - Move right, word by wordDelete - Delete characters after the cursorBackspace - Delete ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
713 Views
The primary objective of the Jigsaw project is to introduce the modularity concept to create a module in Java 9 and then applying the same to JDK.Below are some of the benefits of Modularity(Jigsaw)Strong Encapsulation: The modules can access only those parts that can be available for use. Unless the package is explicitly exported into the module-info.java file, public classes in a package can't be public.Clear Dependencies: A module must declare about other modules that they are used through the required clause. The modules are combined in order to create a shorter runtime that can be scaled to comparatively smaller computing ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
1K+ Views
Since Java 9, the readNBytes() method can be added to the InputStream class. This method reads the requested number of bytes from an input stream into the given byte array. This method blocks until len bytes of input data have read, end of a stream is detected, or an exception is thrown. The readNBytes() method doesn't close an input stream. This method can be useful to avoid memory problems with large files.Syntaxpublic int readNBytes(byte[] b, int off, int len) throws IOExceptionIn the below example, we have created a "Technology.txt" file in the source folder with simple data: { "JAVA", "PYTHON", ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
210 Views
A module is a container of packages and each module contains a module descriptor that includes module name, module dependencies, it means that the name of other modules depends on and name of the packages it exports that can be used only by modules that depend on it.module com.tutorialspoint.app { /** Modules upon which the module com.tutorialspoint.app depends on */ requires com.tutorialspoint.services; /** Packages exposed by this module which can be used by other modules */ exports com.tutorialspoint.app.util; }There are three different compilation modes provided by Java 9 Module: Legacy mode, single module mode, and multi-module mode.Compilation modes of ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
259 Views
JShell can provide an interactive shell for quickly prototyping, debugging, and learning Java and Java API without the need for the main() method or need to compile our code before executing it.Declaration of Class:We can declare a class just like we have written a code in Java Language. The JShell can detect when the class completes it.In the below code snippet, we can declare a class Employee with two parameters and one method.C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> class Employee { ...> String empName; ...> ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
7K+ Views
Since Java 9, we can use the readAllBytes() method from InputStream class to read all bytes into a byte array. This method reads all bytes from an InputStream object at once and blocks until all remaining bytes have read and end of a stream is detected, or an exception is thrown.The reallAllBytes() method can't automatically close the InputStream instance. When it can reach the end of a stream, the further invocations of this method can return an empty byte array. We can use this method for simple use cases where it is convenient to read all bytes into a byte array and not ... Read More