Questions
Java questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Fix Hibernate Unsaved Transient Instance Errors in Java
Learn why Hibernate throws the unsaved transient instance error and how to fix entity relationships with persistence, cascades, and mappings.
Fix PKIX Path Building Failed in Java SSL Certificates
Learn why Java reports PKIX path building failed, how TLS certificate chains and truststores work, and how to diagnose HTTPS trust errors safely.
Fix SLF4J StaticLoggerBinder Errors in Java Application Servers
Learn why SLF4J StaticLoggerBinder errors happen in Java servers and how to package one compatible logging binding in a WAR.
Fix “Source Release 8 Requires Target Release 1.8” in IntelliJ Java
Fix IntelliJ javac source release 8 requires target release 1.8 by aligning Java source and bytecode target settings in projects.
Flatten a List of Lists into a List in Java 8
Learn how to flatten a Java 8 List<List<Object>> into one ordered List<Object> with streams, flatMap, collectors, and safe examples.
Generate Random Integers in a Range in Java
Learn how to generate random integers within a specific range in Java correctly, avoid overflow bugs, and use Random and ThreadLocalRandom safely.
Get a Generic Type Class in Java: Why T.class Does Not Work
Learn why Java cannot use T.class in generic code and how to pass Class<T> safely using type tokens and reflection-aware patterns.
Get the Current Date and Time in Java with java.time
Learn how to get the current date, time, and timestamp in Java using LocalDate, LocalDateTime, Instant, ZoneId, and Clock.
HashMap vs Hashtable in Java: Differences, Performance, and When to Use Each
Learn the differences between HashMap and Hashtable in Java, including thread safety, null handling, performance, and when to use each.
HashMap vs LinkedHashMap vs TreeMap in Java
Learn the difference between HashMap, LinkedHashMap, TreeMap, and Hashtable in Java with examples, ordering rules, and use cases.
Hibernate hbm2ddl.auto Values Explained: validate, update, create, create-drop, and schema strategies
Learn Hibernate hbm2ddl.auto values, what each option does, when to use update, and safer alternatives for schema changes in real projects.
How Android SDK Finds the JDK on Windows
Learn why Android SDK setup may not detect the JDK on Windows and how Java paths, environment variables, and 32/64-bit tools affect it.
How Java Servlets Work: Instantiation, Sessions, Instance Variables, and Multithreading
Learn how Java servlets handle instantiation, sessions, shared variables, and multithreading for multiple users and requests.
How the Enhanced for-each Loop Works in Java
Learn how Java's enhanced for-each loop works, its equivalent standard loops, limitations, and when to use iterators or index-based loops.
How to Add Local JAR Files to a Maven Project in Java
Learn how to use local JAR files in a Maven project, including system scope, installing to a local repository, and best practices.
How to Assert Exceptions in JUnit Tests
Learn how to test that code throws exceptions in JUnit using expected exceptions, assertThrows, and clean test patterns.
How to Avoid Null Checks in Java
Learn practical ways to avoid repeated null checks in Java, prevent NullPointerException, and write cleaner, safer code.
How to Break Out of Nested Loops in Java
Learn how to break out of nested loops in Java using labeled break, flags, and cleaner control-flow patterns with examples.
How to Call One Constructor from Another in Java
Learn how constructor chaining works in Java, how to call one constructor from another, and when to use this() and super().
How to Change the Default Java JDK Version on macOS
Learn how to view, set, and switch the default Java JDK version on macOS using java_home, shell profiles, and practical examples.