O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The code snippets entered at the jshell prompt are wrapped with just enough code to execute them. So, variable, method and class declarations get wrapped within a class and expressions get wrapped within a method which is in turn wrapped within the class. Other things such as imports and class definitions remain as is because they are top-level entities that is, wrapping a class definition within another class is not required as a class definition is a top level entity and can exist by itself. Similarly, in Java, import statements can occur by themselves and they occur outside of a class declaration and hence need not be wrapped inside a class. 

In the subsequent recipes, we will see how to define a method, import additional ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required