O'Reilly logo

Java 9 Programming By Example by Peter Verhas

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

Classes

Now that we have looked at the actual code lines and have understood how the algorithm works, let's look at the more global structures of the code that brings it together: classes and packages enclosing the methods.

Every file in a Java program defines a class. Any code in a Java program is inside a class. There is nothing like global variables or global functions as in C, Python, Go, or other languages. Java is totally object oriented.

There can be more than one class in a single file, but usually one file is one class. Later, we will see that there are inner classes when a class is inside another class, but, for now, we will put one class into one file.

There are some features in the Java language that we do not use. When the language ...

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