logo
Java Tockens
TOKENS:-
Smallest individual part in a java program is called Token. It is possible to provide any number of spaces in between two tokens.
Ex:-Class Test
{
Public static void main(String[] args)
{
 int a=10;
System.out.println("java tokens");
}
Tokens are--------- class,test,{,,[-----------------------------etc
Print() vs Println ():-
Print():-
Print is used to print the statement into the console and the control is available in the same line.
Ex:- System.out.print("freetimelearning.com");
System.out.print("core java");
Output:-freetimelearning.comcorejava
Println():-
In the println statement Print is used to print the statement into the console and ln represent go to the new line now the control is available in the next line.
Ex:- System.out.println("freetimelearning.com");
System.out.println("core java");
Output: - freetimelearning.com
Core java
Identifiers :-
any name in the java program like variable name,class name,method name,interface name is called identifier.
class Test Test------identifier
{
void add() add-------identifier
{
int a=10; a----------identifiers
int b=20; b----------identifiers
}
};
Rules to declare identifiers:-
1. the java identifiers should not start with numbers,it may start with alphabet symbol and underscore symbol and dollar symbol.
a. Int abc=10;-----valied
b. Int 2abc=20;----not valied
c. Int _abc=30;----valied
d. Int $abc=40;----valied
e. Int @abc=50;---not valied
2. The identifier will not contains symbols like
+ , - , . , @ , # , *
3. The identifier should not duplicated.
class Test
{
void add()
{
int a=10;
int a=20; the identifier should not be duplicated.
}
};
In the java applications it is possible to declare all the predefined class names and predefined interfaces names as a identifier. But it is not recamanded to use.
class Test
{
public static void main(String[] args)
{
int String=10; //predefind String class
int Serializable=20; //predified Seriaiable class
float Exception=10.2f; //predefined Exception class
System.out.println(String);
System.out.println(Serializable);
System.out.println(Exception);
}
};