Raja has Published 760 Articles

How to re-execute existing snippets in JShell in Java 9?

raja

raja

Updated on 23-Mar-2020 13:36:57

123 Views

JShell is the first REPL tool introduced in Java 9. We can able to execute simple snippets in a command-line prompt by using JShell tool. We can start a JShell session by typing "jshell" command, stop the session by typing "/exit" command, and search for particular command by using "/help" command.The ... Read More

Differences between Java 8 and Java 9?

raja

raja

Updated on 23-Mar-2020 10:56:46

2K+ Views

Java 9 version has introduced new enhancements and added new features. It includes JShell, Http2Client, Java Platform Module System (JPMS), Multi-release jar files, Stack Walking API, Private methods in an interface, Process API updates, Collection API updates, Stream API improvements, and etc.Below are the few differences between Java 8 and ... Read More

How can we execute snippets by ID in JShell in Java 9?

raja

raja

Updated on 23-Mar-2020 06:40:39

152 Views

JShell is an interactive tool (REPL) introduced in Java 9. We can execute snippets like expressions, variables, methods, classes, and etc without a main () method in the JShell tool.We can execute any prior snippet by simply typing /id, which indicates the snippet’s ID. For instance, if we type "/1", then JShell can ... Read More

How can we avoid compilation errors in JShell in Java 9?

raja

raja

Updated on 20-Mar-2020 18:02:14

150 Views

JShell is an interactive tool that enables us to execute java code and displays the output instantly. JShell is the REPL(Read-Evaluate-Print-Loop) tool that runs from the command-line prompt. If we need to avoid the compilation-errors in JShell, then we must declare those variables before using it. The error message in JShell can ... Read More

How can we implement a map in JShell in Java 9?

raja

raja

Updated on 20-Mar-2020 08:09:49

226 Views

JShell is a java shell tool that has introduced in Java 9. It is an interactive tool that reads input, executes it, and prints it in the command-line prompt. We don't need to write a main() method to execute it like Java class.We can implement different collections includes set, list, ... Read More

What are the components in a module-info file in Java 9?

raja

raja

Updated on 20-Mar-2020 07:07:25

1K+ Views

A module is an independent unit of application that represents a single functionality. A module contains three important componentsName: To uniquely identify itDependencies: Other modules in which it depends onExported packages: Packages which are open for external applicationIn order to declare a module, we need to add the "module-info.java" file ... Read More

How can we display all module names in Java 9?

raja

raja

Updated on 19-Mar-2020 14:02:31

262 Views

In Java 9, the module concept has introduced. It is a named, self-describing collection of code and data. The code can be organized as a set of packages containing types like java classes and interfaces, and data includes resources and other kinds of static information. A module contains a name, ... Read More

How to print the pattern of stars in JShell in Java 9?

raja

raja

Updated on 19-Mar-2020 12:10:10

219 Views

JShell is a REPL tool introduced in Java 9 that allows us to execute Java code and getting results immediately. We can evaluate expressions or simple algorithms without creating a new project, compile or build it by using JShell. We can also execute expressions, use imports, define classes, methods, and variables. It is ... Read More

What are Compact Strings in Java 9?

raja

raja

Updated on 19-Mar-2020 09:17:42

259 Views

Since Java 9, the JVM optimizes strings by using a new feature called Compact Strings. Instead of having a char[] array, a string can be represented as a byte[] array. We can use either UTF-16 or Latin-1 to produce either one or two bytes per character. If JVM detects the string contains only ISO-8859-1/Latin-1 ... Read More

How to display all stack frames of the current thread in Java 9?

raja

raja

Updated on 19-Mar-2020 07:36:28

255 Views

Stack Walking API can provide a flexible mechanism to traverse and extract information from call stacks that allow us to filter and access frames in a lazy manner. StackWalker class is an entry point to Stack Walking API. The stack trace is a representation of a call stack at a certain point ... Read More

Advertisements