What Are JUnit and TestNG? Java Testing Frameworks
Compare JUnit 5 and TestNG: annotations, parameterized tests, grouping, dependencies and parallel execution, plus guidance on which to choose for a new project.
2,889 posts about Java: questions with answers, tutorials and articles, newest first.
Compare JUnit 5 and TestNG: annotations, parameterized tests, grouping, dependencies and parallel execution, plus guidance on which to choose for a new project.
Running Java needs a JDK or runtime from a current LTS release, a supported 64-bit OS and modest hardware. Here is how to install and verify it.
Uninstalling Java is safe when no application depends on it. Check dependants first, then remove it on Windows, macOS or Linux and reinstall a supported LTS if needed.
Install a current JDK on Windows 11, set JAVA_HOME and PATH, and verify with a first program. Browser Java plugins no longer exist.
Java 11 is free to use if you choose an OpenJDK build such as Temurin or Corretto. Oracle JDK 11 needs a subscription for production.
The Observer pattern decouples a subject from its listeners. Modern Java example with records and lambdas, plus Flow and PropertyChangeSupport.
A synchronized block locks only the code that touches shared state. See how to pick the lock, avoid deadlocks and when to use ReentrantLock instead.
A practical guide to Java application security: injection defence, AES-GCM encryption, password hashing, TLS and patching, with modern code examples.
The Java Security Manager restricted untrusted code, but it is deprecated since Java 17 and disabled in Java 24. See how it worked and which alternatives replace it.
Type erasure removes generic type arguments after compile-time checking. Learn what the compiler generates, what you cannot do, and the standard workarounds.
Bounded type parameters limit which types a Java generic accepts using extends. See upper bounds, multiple bounds, Comparable and the PECS wildcard rule.
Declare a generic class with a type parameter such as Box<T>, add bounds and generic methods, and learn what type erasure does and does not allow.
Generics give Java compile-time type safety and reusable code. See generic classes, methods, bounds, wildcards and the restrictions of type erasure.
instanceof tests an object's runtime type and is false for null. See safe casting, pattern matching since Java 16, equals methods and record patterns.
Get a Class object and use getDeclaredFields, getDeclaredMethods and getDeclaredConstructors to inspect a type at runtime, including annotations and generics.
Java reflection inspects and uses classes, methods and fields at runtime. See examples, real-world uses, performance and module limits, and modern alternatives.
A Java transaction runs several operations as one unit that commits or rolls back together. See JDBC code, isolation levels, Spring @Transactional and when JTA is needed.
Statement runs static SQL, PreparedStatement binds parameters safely, and CallableStatement calls stored procedures. Learn which to use and why.
Connect Java to a database with JDBC using try-with-resources, PreparedStatement, transactions and a HikariCP pool, with the current MySQL driver.
JDBC is the standard Java API for connecting to relational databases, running SQL and managing transactions. See how it works with current best practices.