Mega Code Archive

 
Categories / Java Book / 001 Language Basics
 

0001 Create your first Java program

Let's start by compiling and running the following short sample program. /* This is a simple Java program. Call this file "Example.java". */ public class Example { // Your program begins with a call to main(). public static void main(String args[]) { System.out.println("Java."); } } In Java, a source file is called a compilation unit. It is a text file that contains one or more class definitions. The Java compiler requires that a source file use the .java filename extension. In Java, all code must reside inside a class. By convention, the name of the public class should match the its file name. And Java is case-sensitive.