From the course: Java 11+ Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Explore basic Java syntax

Explore basic Java syntax - Java Tutorial

From the course: Java 11+ Essential Training

Start my 1-month free trial

Explore basic Java syntax

- [Instructor] Java is a C style language. That means it shares syntax with C, C++, and other similar languages, but it has its own unique set of rules. First of all, all Java code is defined in classes. A class is defined in a source code file with a .java file extension. In order to turn that file into bytecode, you use the javac command, that's the compiler. And then, the bytecode can be run on top of the virtual machine. You start the virtual machine with the java command. Here's what a simple class looks like. The first line is called the package declaration. This indicates where the file is stored in terms of the directory structure of the application, but it's also a tool for organizing your code. Next, is the class declaration. There might be other lines between the package and the class depending on the needs of your code. The class declaration can start with an access modifier such as public, private, or…

Contents