Professional Documents
Culture Documents
Java Notes
Java Notes
Java Notes
Language Fundamentals:
Identifiers
Reserved Words
Data Types
Literals
Arrays
Types Of Variables
Var-ary Methods
Main Method
Command Line Arguments
Java Coding Standards.
Identifiers:
Name in Java program is known as Identifiers ,which can be used for identification.
Class name
Method name
Label name
Variable name
Ex: class test{
public static void main (string[] args){
int x=10
}
Rules of Identifiers:
A to Z, a to z, 0-9, $ ,_ .
Identifiers cannot start with digit .
Ex: 123total
It is a case sensitive.
Ex: class test {
int number=10;
int Number=10;
int NUMBER=10
}
There is no length limit for java identifier. But it is not recommended to take lengthy
identifier.
We cannot use reserved keywords as identifiers.
Ex: int x=10
Int if=10
All pre-defined java class name can be used as identifiers but it is not recommended.
Because it causes readability and confusion.
Reserved word:
Java has 53 reserved keywords.
Keywords should be lowercase, no special characters and numbers.
There is Delete keyword. Because destruction of useless object is the responsible for
garbage collector.
In java some words are reserved words are used to represent some meaning or
functionality , such type of words are called reserved words.
Reserved literals True, False, Null(Default value for Object Reference).
Used keywords ->48, used ->2(goto,const)
(i.e.., Usage of goto created several problems in old language and hence some people
banned this keyword in java .Use final instead of const.) COMPILIER ERROR.
Keywords for Datatypes(8) -> byte,short,int,long,float,double,Boolean,char.
Keywords for Flow-Control(11) ->
if,else,switch,case,default,while,do,for,break,continue,return.
Keyword for Modifiers(11)
->public,private,protected,static,final,abstract,synchronized,native,strictfp,transient,volatil
e.
Keyword for Exemptional-Handling(5) -> try,catch,filehandling,throw,essert.
Keyword for Class-Related(6)-> class,interface,extends,implements,package,import.
Keywords for Object(4) ->new,instanceof,super,this.
Keyword for Return(1) ->void (if the method won’t return anything we can use void).
(i.e.., In Java return type is mandatory if a method return anything then we have to
declare that method with void return type, but in ‘c language’ return type is optional and
default return type is int).
Enem(we can use enem to define a group of named constants).
Ex: enem month{
Jan, Feb ,… Dec,
}
strictfp(1.2v) , assert(1.4v), enem(1.5v) -> New keywords in java.
Data Types: