Java
Java
Platform Independence
Object-Oriented
Robust
Secure
Portable
Multithreaded
Automatic Memory Management
Versatile Standard Libraries
Scalable
Java Platform
The platform is independent of any specific hardware or operating system due to the Java
Virtual Machine (JVM).
Data Types
Variables in Java
Local Variables
Instance Variables
Arrays in Java
One-Dimensional Array
Multi-Dimensional Array
{1, 2, 3},
{4, 5, 6}
};
Expressions in Java
Types of Expressions
int x = 10;
5. Conditional Expressions: Use the ternary operator for compact decision-making.
Operators in Java
Control Structures in Java
1. Decision-Making Statements
if Statement:
if (x > 0) {
System.out.println("Positive number");
}
if-else Statement:
if (x > 0) {
System.out.println("Positive");
} else {
System.out.println("Negative or zero");
}
if-else-if Ladder:
if (x > 0) {
System.out.println("Positive");
} else if (x < 0) {
System.out.println("Negative");
} else {
System.out.println("Zero");
}
switch Statement:
switch (day) {
case 1: System.out.println("Monday"); break;
case 2: System.out.println("Tuesday"); break;
default: System.out.println("Other day");
}
2. Looping Statements
for Loop:
while Loop:
int i = 0;
while (i < 5) {
System.out.println(i);
i++;
}
do-while Loop:
int i = 0;
do {
System.out.println(i);
i++;
} while (i < 5);
3. Jump Statements
if (x < 0) return;