Professional Documents
Culture Documents
Java Program
Java Coding Guidelines
Java Comments
Java Identifiers
Java Keywords
Java Literals
Java Data Types
Java Variables
Java Constant
*Property of STI J0007
A minimum Java program has the following
format:
Java
Statements Example:
System.out.print(“Hello, World!”);
Java
Comments // This is a comment
/* This is a comment */
/** This is a special comment **/
/** for documentation **/
Comments */
public static void main (String[] args) {
// print “Hello, World!” on screen
System.out.println(“Hello, World!”);
}
}
Case-sensitive
Java May contain letters, digits, underscore and
Identifiers dollar sign ($)
Integers
Floating Point Numbers
Booleans (true or false)
Strings (enclosed in “ “)
Java Literals Characters (enclosed in ‘ ‘)
\n new line
\t tab
\r carriage return
\” double quote
\’ single quote
\\ backslash
Character
Literal Some characters, such as the newline character, don't
have visible literal representations. For these, an escape
sequence must be used, which consists of the backslash
("\") followed by a code.
Simple
built-in or primitive Java data types
Data Types
Composite
created by the programmer using simple
types, arrays, classes, and interfaces
Floating Point
Data Type
Declaring
and int yourAge = 19;
Initializing
Variables Semicolon
Data type Optional: assigned value
System.out.println(value);
System.out.println(“The value of x = ” + x);
}
}
System.out.println()
Displaying Appends a newline at the end of the data output
Variable Data Example:
System.out.println(“Hello”);
System.out.println(“World”);
Output:
Hello
World