Java History & Features
In this page:
History of Java
James Gosling led the team that created Java at Sun Microsystems, first releasing it in 1995 under the name Oak before renaming it Java -- the goal from the start was a simpler, safer alternative to C++.
Example: History of Java
public class Main {
public static void main(String[] args) {
String originalName = "Oak";
String releaseYear = "1995";
System.out.println("Java was created by James Gosling at Sun Microsystems in " + releaseYear + ", originally named " + originalName + ".");
}
}
Login to try C/C++/Java/PHP code in the editor
Platform Independence
Because the compiler targets bytecode instead of a specific CPU's machine code, the exact same compiled program runs unmodified on any operating system that has a JVM installed.
Example: Platform Independence
public class Main {
public static void main(String[] args) {
// This same Main.class file runs unmodified on Windows, Linux, and macOS
System.out.println("Compiled once, runs on any OS with a JVM installed.");
}
}
Login to try C/C++/Java/PHP code in the editor
Object-Oriented Programming
Java forces you to model your program as classes and objects from the ground up, which encourages breaking large problems into smaller, testable, reusable pieces rather than one long procedural script.
Example: Object-Oriented Programming
class Task {
String name;
Task(String name) { this.name = name; }
void run() { System.out.println("Running: " + name); }
}
public class Main {
public static void main(String[] args) {
Task task = new Task("Send Email");
task.run();
}
}
Login to try C/C++/Java/PHP code in the editor
Robustness and Security
The JVM validates bytecode before running it, enforces array bounds checking, and gives you no raw pointers to corrupt memory with -- trade-offs that sacrifice some raw speed for far fewer crash-causing bugs.
Example: Robustness and Security
public class Main {
public static void main(String[] args) {
int[] numbers = {1, 2, 3};
try {
System.out.println(numbers[5]); // out-of-bounds access
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Caught by JVM bounds checking: " + e.getMessage());
}
}
}
Login to try C/C++/Java/PHP code in the editor
Multi-threading Support
Since threads are a first-class part of the language (via the Thread class and java.util.concurrent), you can genuinely run independent tasks in parallel to keep a CPU-bound or I/O-bound program responsive.
Example: Multi-threading Support
public class Main {
public static void main(String[] args) throws InterruptedException {
Thread worker = new Thread(() -> System.out.println("Running independently on its own thread"));
worker.start();
worker.join();
}
}
Login to try C/C++/Java/PHP code in the editor
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: