Features of Java – Explained with Examples
Java became one of the world's most popular programming languages because of a set of design goals often called the Java buzzwords: simple, object-oriented, portable, secure, robust, multithreaded, high-performance and more. These features explain why Java is chosen for banking systems, Android apps and large web services alike.
This tutorial explains each feature in plain words, with short examples where code helps.
1. Key Features of Java
2. Simple
Java's syntax is based on C and C++, so it looks familiar, but it removes their most error-prone parts:
- No explicit pointers or pointer arithmetic.
- No manual memory freeing; the garbage collector does it.
- No user-defined operator overloading (only built-in cases such as
+for strings) and no multiple inheritance of classes. - No header files or preprocessor macros.
Modern features such as var, records and text blocks make everyday code even shorter.
3. Object-Oriented
Everything in Java lives inside classes. You model real-world things as objects that combine data and behaviour, and you use the four OOP principles: encapsulation, inheritance, polymorphism and abstraction. In this example two payment types share one interface but calculate fees differently:
import java.util.List;
public class ObjectOrientedFeature {
interface Payment { double fee(double amount); String name(); }
static class Card implements Payment {
public double fee(double amount) { return amount * 0.02; }
public String name() { return "Card"; }
}
static class Upi implements Payment {
public double fee(double amount) { return 0; }
public String name() { return "UPI"; }
}
public static void main(String[] args) {
List<Payment> options = List.of(new Card(), new Upi());
for (Payment p : options) { // same call, different behaviour
System.out.println(p.name() + " fee on 1000: " + p.fee(1000));
}
}
}
Card fee on 1000: 20.0 UPI fee on 1000: 0.0
4. Platform-Independent
C and C++ compilers produce machine code for one specific operating system and processor. Java compiles source code into bytecode, a neutral format that any Java Virtual Machine can run. Windows, macOS and Linux each have their own JVM, so the same .class file runs on all of them: "Write Once, Run Anywhere".
Hello.java --javac--> Hello.class (bytecode) --+--> JVM on Windows --> runs
+--> JVM on macOS --> runs
+--> JVM on Linux --> runs
Note the difference: Java programs are platform-independent, but the JVM itself is platform-specific.
5. Portable
Portability goes beyond running everywhere. Java defines the exact size of every primitive type, so an int is always 32 bits and a long always 64 bits, and the language specification fixes the evaluation order of expressions. Since Java 17, all floating-point arithmetic follows the same strict IEEE 754 rules on every platform, and since Java 18 the default character set is UTF-8 everywhere. Arithmetic therefore gives the same result on every machine. For bit-for-bit identical results from functions such as sin() or pow(), use StrictMath; Math may use faster platform-specific implementations.
6. Architecture-Neutral
Bytecode does not depend on a processor's instruction set, word size or byte order. The JVM translates bytecode into the right instructions for x86, ARM or any other architecture, so the compiled program does not change when the hardware does.
7. Secure
- No pointers: code cannot read or write arbitrary memory addresses.
- Bytecode verifier: checks every class before running it, rejecting code that breaks type rules or the stack.
- Array bounds and type checks at runtime prevent buffer overflows.
- Class loaders separate code from different sources.
- Security APIs: cryptography, TLS, certificates and authentication are part of the platform.
- No Security Manager: the old Security Manager sandbox was deprecated in Java 17 and permanently disabled in Java 24. Modern Java relies on the mechanisms above plus operating-system and container isolation.
8. Robust
"Robust" means reliable. Java catches many errors at compile time thanks to strong static typing, and handles runtime problems through exceptions instead of crashing:
public class RobustFeature {
public static void main(String[] args) {
int[] scores = {90, 75, 60};
try {
System.out.println(scores[3]); // no such index
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Caught safely: " + e.getMessage());
}
String name = null;
try {
System.out.println(name.length());
} catch (NullPointerException e) {
System.out.println("Caught safely: NullPointerException");
}
System.out.println("The program keeps running.");
}
}
Caught safely: Index 3 out of bounds for length 3 Caught safely: NullPointerException The program keeps running.
Automatic garbage collection removes another big class of bugs: leaks from forgetting to free memory, dangling pointers, and crashes from freeing memory twice. A Java program can still leak memory if it keeps references to objects it no longer needs, for example in a growing static collection.
9. Multithreaded
Java can run several tasks at the same time. Threads, thread pools, locks, concurrent collections and, since Java 21, lightweight virtual threads are all built in. Here three slow calls run concurrently instead of one after another:
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class MultithreadedFeature {
public static void main(String[] args) throws Exception {
// Java 21 virtual threads: cheap threads for many small tasks
try (ExecutorService pool = Executors.newVirtualThreadPerTaskExecutor()) {
List<Future<String>> results = new ArrayList<>();
for (String city : List.of("Delhi", "Pune", "Goa")) {
results.add(pool.submit(() -> {
Thread.sleep(100); // pretend to call a weather service
return city + ": sunny";
}));
}
for (Future<String> f : results) {
System.out.println(f.get());
}
}
}
}
Delhi: sunny Pune: sunny Goa: sunny
See Multithreading in Java for the details.
10. High Performance
Java used to be called slow because early JVMs only interpreted bytecode. Modern JVMs use a Just-In-Time (JIT) compiler: they watch which methods run most often ("hot spots") and compile them into highly optimised native code while the program runs. They can even optimise based on how the program actually behaves, something a traditional compiler cannot know in advance. For long-running servers, Java's performance is often comparable to C++. Since Java 24, an ahead-of-time (AOT) cache can also shorten start-up time (see Java 25 updates).
11. Distributed
Java was designed for networked computing. The standard library includes sockets, URLs, an HTTP client (java.net.http, Java 11) and Remote Method Invocation (RMI). Frameworks build on these to create microservices that talk to each other across machines.
12. Dynamic
Java loads classes only when they are first needed, and a program can inspect and use classes it did not know about when it was compiled. This is the basis of plug-ins, dependency injection (Spring) and many frameworks:
import java.lang.reflect.Method;
public class DynamicFeature {
public static class Greeter {
public String greet(String who) { return "Hello, " + who + "!"; }
}
public static void main(String[] args) throws Exception {
// Load a class by name at runtime and call one of its methods
Class<?> type = Class.forName("DynamicFeature$Greeter");
Object greeter = type.getDeclaredConstructor().newInstance();
Method greet = type.getMethod("greet", String.class);
System.out.println("Loaded class: " + type.getSimpleName());
System.out.println(greet.invoke(greeter, "Java"));
}
}
Loaded class: Greeter Hello, Java!
13. Compiled and Interpreted
Java uses a two-stage approach. The javac compiler checks the code and turns it into bytecode; the JVM then interprets that bytecode and JIT-compiles the busy parts. You get early error checking from the compiler and portability and runtime optimisation from the JVM.
14. Other Strengths of Java
- Huge standard library: collections, I/O, networking, date-time, concurrency, XML and more.
- Rich ecosystem: Spring Boot, Hibernate, Maven, Gradle, JUnit, and millions of open-source libraries.
- Backward compatibility: code written decades ago usually still compiles and runs.
- Excellent tooling: IntelliJ IDEA, Eclipse, VS Code, profilers and debuggers.
- Steady evolution: a new release every six months, with LTS versions for stability.
15. Java Version Improvements and Java 25 Updates
The core features above date back to Java 1.0, but recent releases have strengthened several of them. Every item below is a standard (final) feature unless marked otherwise:
| Java version | Feature | Change |
|---|---|---|
| Java 17 | Portable | All floating-point arithmetic is strict on every platform; strictfp no longer has any effect. |
| Java 18 | Portable | UTF-8 is the default character set on every operating system. |
| Java 21 | Multithreaded | Virtual threads make it cheap to run thousands of concurrent tasks. |
| Java 24 | Secure | The Security Manager is permanently disabled. |
| Java 24 | High performance | AOT class loading and linking: an AOT cache made from a training run speeds up start-up. |
| Java 25 | High performance | AOT command-line ergonomics (one-step -XX:AOTCacheOutput) and AOT method profiling for faster warm-up. |
| Java 25 | High performance | Compact object headers become a product feature (off by default; enable with -XX:+UseCompactObjectHeaders) to reduce memory use. |
| Java 25 | Simple | Compact source files and instance main methods for shorter beginner programs. |
A worked example of the AOT cache is in JDK vs JRE vs JVM, and compact source files are shown in How to Write a Java Program.
16. Summary
- Java is simple, object-oriented and strongly typed.
- Bytecode and the JVM make Java platform-independent, portable and architecture-neutral.
- Security comes from no pointers, bytecode verification and runtime checks.
- Robustness comes from static typing, exceptions and garbage collection.
- Built-in multithreading, JIT compilation and dynamic class loading make Java fast and flexible.
17. Official Java Documentation References
- The Java Language Specification, Java SE 25 Edition
- The Java Virtual Machine Specification, Java SE 25 Edition
- JVMS §4.10: Verification of class Files
- java.lang.StrictMath (Java SE 25 API)
- JEP 306: Restore Always-Strict Floating-Point Semantics
- JEP 400: UTF-8 by Default
- JEP 444: Virtual Threads
- JEP 486: Permanently Disable the Security Manager
- JEP 483: Ahead-of-Time Class Loading & Linking
- JEP 514: Ahead-of-Time Command-Line Ergonomics
- JEP 515: Ahead-of-Time Method Profiling
- JEP 519: Compact Object Headers
- Oracle: The Java Language Environment (original design white paper)