1. class A{
public static void main(String args[]){
main method
System.out.println(“My Program”);
The command given to print. A type of a
method
}
}
Key word
Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
3. package abc;
import java.util.ArrayList;
public class A{
}
class B{
}
class C{
}
Class declaration
More than one non public
Only one Can have many
A.java
If public must
match
Remember Order
PIC
Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
4. m( ) {
return []; //return statement
}
Return type
Modifiers
Parameter list
m=method name
Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
There can’t be methods
inside methods
6. class A{
public static void main(String args[]){
}
}
Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
machines=methods
factory = class
7. Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
class A{
}
class B{
}
class C{
public static void main(String args[]){
}
}
D.java
Javac D.java
Java C
8. int i;
Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
Declaration
i =5; Assignment
int i=5; Declaration and Assignment
Or called Field
int i=5;
Data type
Variable name
Value
10. Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
10 10
byte i=10; int i=10;
Differs from memory allocation in the RAM
11. float f=3.14;
Double d=3.14;
float f=(float)3.14;
float f=3.14f; // F or f
double d=3.14d; // D or d
Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
14. Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
m( ) {
return []; //return statement
}
}
class A{
Like an arm in a
machine
What should be
out put. Data
types are used
15. There ‘s no return
statement.
Nothing is out put.
Like armless Machine.
Creation of Sajitha Tharaka-
sajithatharaka@gmail.com
static void flag(byte a){
System.out.println("A");
}
static void name(int x){
System.out.println("B");
}
static void age(short y){
System.out.println("C");
}