Java Learning Guide - Step by Step
Chapter 1: Introduction to Java
Java is a high-level, object-oriented, platform-independent language. You write once and run anywhere.
Structure:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
Explanation: 'public static void main' is the entry point.
Task: Print your name, college, and favorite subject.
Chapter 2: Data Types and Variables
Basic Types:
int age = 20;
float marks = 85.5f;
char grade = 'A';
boolean isPass = true;
String name = "Ravi";
Task: Declare and print your details.
Chapter 3: Operators
Java Learning Guide - Step by Step
Operators:
Arithmetic: + - * / %
Relational: > < == !=
Logical: && || !
Example:
int a = 10, b = 20;
System.out.println(a + b); // 30
Task: Take two numbers, show all operations.
Chapter 4: Conditional Statements
If-Else:
int marks = 70;
if (marks >= 50) System.out.println("Pass");
else System.out.println("Fail");
Switch:
int day = 3;
switch (day) { case 1: System.out.println("Sunday"); break; ... }
Task: Write a grade calculator.
Chapter 5: Loops
For Loop:
for (int i = 1; i <= 5; i++) System.out.println(i);
Java Learning Guide - Step by Step
While Loop:
int i = 1;
while (i <= 5) { System.out.println(i); i++; }
Task: Print multiplication table.
Chapter 6: Arrays
Array:
int[] marks = {90, 80, 70};
System.out.println(marks[1]); // 80
2D Array:
int[][] matrix = {{1, 2}, {3, 4}};
Task: Find average of 5 student marks.
Chapter 7: Strings
String Methods:
length(), toUpperCase(), charAt()
Example:
String s = "Java";
System.out.println(s.length());
Task: Take a name and print reverse.
Java Learning Guide - Step by Step
Chapter 8: OOP Concepts
Class & Object:
class Student { String name; void show() { ... } }
Constructor: Student(String n) { ... }
Inheritance:
class Animal { void eat(){} }
class Dog extends Animal { void bark(){} }
Task: Create class Car with brand and model.
Chapter 9: Exception Handling
Try-Catch:
try { int a = 5/0; } catch (Exception e) { System.out.println("Error"); }
Chapter 10: File Handling
FileWriter fw = new FileWriter("output.txt");
fw.write("Hello File"); fw.close();
Chapter 11: Collections (Intro)
ArrayList:
Java Learning Guide - Step by Step
ArrayList<String> names = new ArrayList<>();
names.add("Ravi");
System.out.println(names.get(0));
Chapter 12: Mini Projects Ideas
1. ATM Simulator
2. Simple Calculator
3. Student Marks Report
4. Quiz Game