Click
here
for the codes below.
- All codes are case sensitive.
- Blank line and Indentation
- Blank lines, spaces, and tabs are white-space characters
- You can use any number of spaces and line breaks to separate words.
But, you should make program more readable.
- Block comment:
- Start with /*,
and end by */.
- It can be two or more lines.
- It provides program reader with
information.
- It shows who wrote the
program.
- It also shows the purpose of
the program.
- The compiler
will not read the block.
- Line comment:
- Start with //,
end at the end of line.
- Tell the compiler to
ignore the
rest of that particular line.
- It is a place, the programmer can write a remark to remind himself
or reader.
- Each statement end with
;
- Beginning and ending braces:{}
to block the class, method, loop.
- public
class ClassName{}
Classes
are the fundamental building blocks of Java programs.
The keyword public denotes that the class is usable by the "public".
Every Java program consists of at least one class that the programmer
define.
That is, there is at least one programmer-defined class.
The
file name should be same
as the name of the class
that includes the main
method.
- main method:
public static void main (
String[] args )
The keyword static indicates that the main method does not operate on
an object.
OS starts the program from main method.
-
System.out.println("Welcome to Java
Programming!"
);
uses the System
class from the core
library to print the "Welcome to Java
Programming!" message to
standard output.