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.

javahibernatejpaorm

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.

javassl-certificatehttpurlconnection

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.

javawebsphereslf4j

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.

javaintellij-ideajava-8

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.

javacollectionsjava-8

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.

javarandominteger

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.

javagenerics

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.

javadatetime

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.

javacollectionshashmaphashtable

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.

javadictionary

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.

javahibernatehbm2ddl

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.

javaandroidsdkwindows-7-x64

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.

javamultithreadingservletssession-variables

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.

javaforeachsyntactic-sugar

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.

javamavendependencieslibraries

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.

javaexceptionjunitjunit4

How to Avoid Null Checks in Java

Learn practical ways to avoid repeated null checks in Java, prevent NullPointerException, and write cleaner, safer code.

javanullpointerexceptionnull

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.

javaloopsnested-loops

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().

javaconstructor

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.

javamacos

Page 2 of 9 - 166 questions