From the course: Java 8+ Essential Training: Syntax and Structure
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Java syntax and compilation - Java Tutorial
From the course: Java 8+ Essential Training: Syntax and Structure
Java syntax and compilation
- [Instructor] When you program in Java, you're creating classes. A class is a distinct unit of programming, and in Java, all code is defined in classes. Every class is defined in a source code file, and the top level class in any source code file matches the name of the file itself. It'll have a file extension of .java, and the beginning of the file name is the name of the class. To turn that source code file into a compiled bytecode file, you use the command javac, and then to run that application, you use the command java. Here's what a very simple Java class looks like. Let's say that you had a file named Main.java. The beginning of the file name before the dot has to match the class name, and there's a very strong naming convention that the initial character is always uppercase. The first line of this code is called the package declaration. It indicates the location of the file in the project. A package of com.example indicates that this file is stored in a directory named…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.