Page 57 - Trackpad_ipro 4.1_Class8
P. 57
In the main method:
public means the method is accessible from outside the class.
static means the method belongs to the class rather than to instances of the class.
void means the method does not return a value.
The only term you can change in the syntax of the main( ) method is the name of the parameter 'args',
which can be any valid identifier name. The array of strings (String []) will contain the command-
line arguments, if any, when the program is executed from the command prompt. In BlueJ, we can
also use main() method without any arguments. The main() contains a single statement:
System.out.println("Hello from Trackpad");
This statement is used to display the message "Hello from Trackpad" on the output screen.
System.out represents the standard output of the device where the program is running, and the
println() method displays the given string along with a line feed.
Notice the semicolon at the end of the System.out.println() statement; it terminates the line. It
is also known as the line terminator. The Java compiler ignores all white spacing and indentation,
so it is necessary to use a semicolon to denote the end of all statements in Java.
BASIC FUNDAMENTALS OF JAVA
Like other programming languages, Java also provides some fundamental concepts which are
given below:
Identifiers
Keywords
Data Types
Literals
Variables
Comments
Let us discuss these in detail.
Identifiers
An identifier is the name given to an object in a Java program. It is used to uniquely identify an
object in a program, such as, a class name or a method name.
Rules for Naming Identifiers
The rules for naming identifiers are:
Can consist of letters, digits 0–9, underscore ( _ ), and dollar ($) sign.
Cannot start with a digit.
Keywords cannot be used.
No special symbols like !, @, #, %, etc. can be used.
Identifiers are case-sensitive, which means ‘name’ and ‘NAME’ are two different identifiers.
Program Coding 55

