Java Programming
Comprehensive guided learning module covering syntax, object-oriented principles, exception handling, and the collections framework.
Java is a popular, class-based, object-oriented programming language designed by James Gosling at Sun Microsystems in 1995. It runs on the Write Once, Run Anywhere principle using the Java Virtual Machine (JVM).
Structure of a Java program
Every Java program is written inside a class. The filename must match the public class name (e.g., Main.java). Execution starts from the main method: public static void main(String[] args).
Compilation & JVM
Source .java → Compiler javac → Bytecode .class → JVM java. The JVM interprets/JIT-compiles bytecode into native machine instructions.
Comments
// Single-line comment
/* Multi-line comment */
`/** Javadoc comment used to generate API docs */
Identifiers & Keywords
Names of classes, methods, and variables are identifiers. Keywords like public, class, static, void are reserved by Java.
System.out.println()
Standard output function. System is a class, out is a static print stream, and println is the method that prints text followed by a newline.
Strict Rules
Java is case-sensitive, statements must end with semicolons, and code blocks are enclosed in curly braces {}.
public class Main {
public static void main(String[] args) {
// Print hello message to console
System.out.println("Hello, Java!");
}
}