import java.io.*; public class Hello { public static void main (String[ ] args) { System.out.println("This is a literal print."); System.out.print("Yea!"); System.out.println("Go Java!"); } }
Programs should begin with a comment identifying the purpose of the program and the programmer.
/**documentation */ - documentation commenting. /* text*/ - is the format for block commenting. // text - is the format for single line commenting.
Comment statements are ignored by the compiler. It is a message to the reader of the code.
import java.io.*;
The import command tells the computer to find packages that will be needed in the execution of the program. The java.lang package is the only package imported automatically without an explicit command; all other packages need an import command.
Every Java program is a class. The program starts with the name of the class. This name must be the same name as the . java file in your folder.
Class names must begin with a letter, an underscore or a dollar sign.
Class names may contain only letters, digits, underscores and/or dollar signs.
Class names may not use reserved words.
public static void main (String[ ] args)
A main method is needed for execution to have a place to start. This main method gets executed first. The array of strings parameter is a necessity.
System.out.println("This is a literal print."); System.out.print("Yea!"); System.out.println("Go Java!");
Output statements: the basic output statement in Java is the System.out.println( ) statement.
The System.out.println( ) line will print what is between the double quotes" " (called a literal print) and move the printing cursor to the next line.