Program structure
Every Java program lives inside a class. The entry point is the main method: public static void main(String[] args).
Print to the console with System.out.println("Hello"). Each statement ends with a semicolon, and blocks are wrapped in curly braces.
Variables and types
Java requires you to declare a type before the name. For example: int age = 25; double height = 5.8; boolean isStudent = true; String name = "Aman".
Convert a text value to a number with Integer.parseInt(text) or Double.parseDouble(text).
Classes and objects
A class is a blueprint. Create an object with the new keyword: Student s = new Student();.
A constructor sets up an object when it is created, and the this keyword refers to the current object. Mark fields private and expose them through public getter and setter methods for encapsulation.
Collections
ArrayList is a resizable list: add with list.add(value), read with list.get(index), and check the length with list.size().
HashMap stores key and value pairs: map.put("key", value) and map.get("key"). HashSet stores unique values with no duplicates.