Raja has Published 760 Articles

How to create a process using ProcessBuilder in Java 9?

raja

raja

Updated on 20-Apr-2020 16:24:53

301 Views

Java 9 added ProcessHandle interface to Process API to enhance Process class. An instance of the ProcessHandle interface identifies a local process that allows us to query process status and managing processes, and ProcessHandle.Info allows us to use local code because of the need to obtain the PID of a local process.ProcessBuilder class can be ... Read More

How to create Html5 compliant Javadoc in Java 9?

raja

raja

Updated on 20-Apr-2020 10:20:55

183 Views

Before Java 9, we have to search in google to find out particular packages, class, interface, and method information. Since Java 9, Javadoc includes search options in the API documentation itself, and the output is HTML5 compliant.In the below example, we have created the "JavaDocTest.java" file in the "C:/JAVA" folder.Examplepublic class ... Read More

Importance of Optional.or() method in Java 9?

raja

raja

Updated on 17-Apr-2020 17:40:48

595 Views

In Java 9,  few static methods: stream(), or(), and ifPresentOrElse() have added to Optional class. The introduction of an Optional class solves the null pointer exception.Optional.or() method returns an Optional describing the value if a value is present, otherwise returns an Optional produced by the supplying function. Syntaxpublic Optional or(SupplierRead More

How to create static VarHandle in Java 9?

raja

raja

Updated on 17-Apr-2020 09:28:06

375 Views

VarHandle is a reference to a variable, and it provides access to variables under various access modes (such as plain read/write, volatile read/write, and compare-and-swap), similar to the functionality provided by java.util.concurrent.atomic and sun.misc.Unsafe. The variables can be array elements, instance or static fields in a class.In the below example, we can create a static variable handle.Exampleimport ... Read More

What are the rules for external declarations in JShell in Java 9?

raja

raja

Updated on 16-Apr-2020 19:10:32

79 Views

JShell is a command-line tool introduced in Java 9, and it is Java's first official REPL tool to create a simple programming environment that reads the user's inputs, evaluates it, and prints the result.The declarations outside a class or interface (and declarations of classes and interfaces by themselves) have been created under the following rules.Rules ... Read More

How can we create an instance of VarHandle in Java 9?

raja

raja

Updated on 16-Apr-2020 14:11:28

141 Views

In general, a Variable Handle is simply typed reference to a variable. It will be an array element, an instance or static field of the class. VarHandle class can provide write and read access to variables under specific conditions. These are immutable and have no visible condition. In addition, they ... Read More

How to implement Flow.Publisher interface in Java 9?

raja

raja

Updated on 16-Apr-2020 10:36:29

636 Views

A Publisher interface is a provider of an unbounded number of sequenced elements, publishing them according to the demand received from its Subscriber(s). In response to call Publisher.subscribe(Subscriber), the possible invocation sequences for methods on the Subscriber. It means that the onSubscribe() method, followed by the unbounded number of onNext() ... Read More

How can we implement methods of Stream API in Java 9?

raja

raja

Updated on 15-Apr-2020 17:55:40

169 Views

Stream API provides lots of built-in functionality to help in performing operations on a collection using a stream pipeline. The API is declarative programming that makes the code precise and less error-prone. In Java 9, few useful methods have added to Stream API.Stream.iterate(): This method can be been used as stream version replacement ... Read More

What are the different startup scripts in JShell in Java 9?

raja

raja

Updated on 15-Apr-2020 13:50:12

102 Views

JShell is an interactive Java Shell tool that executes code from the JShell and instantly displays an output. JShell is the REPL (Read-Evaluate-Print-Loop) tool that can run from the command-line prompt.In JShell, there is an option to load a script on startup that includes some special predefined options. These can be specified ... Read More

What are the advantages and disadvantages of the Module System in Java 9?

raja

raja

Updated on 15-Apr-2020 09:54:52

883 Views

A major change in Java 9 version is Module System, and it provides modular JVM that runs on devices with less available memory. The JVM runs with only those modules and API required by an application.module Module-Name { requires moduleName; exports packageName; }Below are ... Read More

Advertisements