Professional Documents
Culture Documents
LESSON # 3.1
TITLE: Understanding the Java Codes
Terminologies
Comments – are additional information added to the code. They are used to describe the program or
portions of the program.
Class Declaration – contains the code that defines the access specifier, class name, and a pair of
curly brackets which contain the body of the class.
Access Specifier – defines the visibility of the class and how other classes can access the class.
Interface – is a common method that the class supports.
Main() Method – Starts the execution of a Java program.
Public Keyword – is an access specifier which indicates the main() method can be called outside the program.
Statements – is a form of a complete command to be executed and can also include one or more expression.
Delimeter – is character or string used to separate or mark the start and end of a program construction or items
of data.
Expression – A type of statement that includes assignment statements, method invocation, object creation,
expressions, and increment statements.
Declaration – A type of statement that is used to declare variables.
Control Statements – A type of statement which determines the order of statements to be executed.
Special Control Statements – a type of statement that includes return, continue and break statements. It is also
known as branching statements.
Reserved Words – are words that have special meaning and function to the Java programming language.
Discussion
Java comments are denoted in three ways:
Class Declaration
The body of the class contains the declaration of class variables and definition of class methods.
Example:
public javacode() {
}
public static void main(String[] args) {
String name;
String label;
double weight_kg;
double weight_lbs;
}
}
String name;
String label;
double weight_kg;
double weight_lbs;
}
Statements
//declaration statement
int number;
//expression statement
number = 4;
//control flow statement
if (number < 10 )
{
//expression statement
System.out.println(number + " is less than ten");
}
Delimeters
Common Delimeters: Curly Braces {}, Parenthesis (), Bracket [], Semi-colon ;
Reserved words
abstract const finally interface return throws