Professional Documents
Culture Documents
2-Fundamentals of Java Language
2-Fundamentals of Java Language
Java Language
Object-Oriented Programming (ITPROG3)
Module 2
BASIC STRUCTURE OF A JAVA CLASS
class HelloWorld{
public static void main(String args[ ]){
System.out.println(“Hello World”);
}
}
2
BASIC STRUCTURE OF A JAVA CLASS
class HelloWorld{
public static void main(String args[ ]){
System.out.println(“Hello World”);
}
}
3
BASIC STRUCTURE OF A JAVA CLASS
class HelloWorld{
public static void main(String args[ ]){
System.out.println(“Hello World”);
}
}
4
BASIC STRUCTURE OF A JAVA CLASS
class HelloWorld{
public static void main(String args[ ]){
System.out.println(“Hello World”);
}
}
5
BASIC STRUCTURE OF A JAVA CLASS
class HelloWorld{
public static void main(String args[ ]){
System.out.println(“Hello World”);
}
}
6
JAVA LANGUAGE FUNDAMENTALS
Identifiers
Keywords
Comments
Data types
7
Identifiers are names that are given by the
programmer as name of variables, methods
or functions, classes etc. The name used as
an identifier must follow the following rules
in Java™ technology:
8
Java keywords are reserved and cannot be used as identifiers.
9
Java Comments are of three (3) types:
10
JAVA DATA TYPES
11
Derived Data Types
String
Date
Integer
Double
Long
Float
…
12
VARIABLES
Variable Declaration
Syntax: <datatype> <varName>; [= value;]
Example: String name;
int age;
double price = 55.66;
Assigning a value
Syntax: <varName> = value;
Example: name = “Maria Blanco”;
age = 22;
price = 200.50;
13
WRAPPER CLASSES
14
Wrapper Class Primitive Type
Integer int
Float float
Double double
Long long
Byte byte
Short short
Character char
Boolean boolean
15
QUESTIONS AND COMMENTS
16