Questions
Java questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Fix NetworkOnMainThreadException in Android (Java)
Learn why Android throws NetworkOnMainThreadException and how to fix it using background threads for network requests in Java.
How to Fix UnsupportedClassVersionError in Java: JRE vs JDK and Version Mismatch
Learn why Java UnsupportedClassVersionError happens, how JRE and JDK differ, and how to fix class version mismatches correctly.
How to Fix javax.xml.bind.JAXBException NoClassDefFoundError in Java 9+
Learn why JAXB is missing in Java 9+ and how to fix javax.xml.bind.JAXBException NoClassDefFoundError with modules or dependencies.
How to Generate a Random Alphanumeric String in Java
Learn how to generate random alphanumeric strings in Java with flexible length, practical examples, uniqueness tips, and common mistakes.
How to Generate an MD5 Hash in Java
Learn how to generate an MD5 hash in Java using MessageDigest, convert bytes to hex, and understand when MD5 should and should not be used.
How to Get the Current Stack Trace in Java
Learn how to get the current stack trace in Java, return it as data, and use StackTraceElement safely in logging and debugging.
How to Get the Current Working Directory in Java
Learn how Java gets the current working directory, why user.dir may show system32, and how to resolve file paths correctly.
How to Initialize a HashMap in Java: Literal-Like Syntax and Best Practices
Learn how to initialize a Java HashMap with fixed values, why Java has no map literal syntax, and the best modern alternatives.
How to Initialize a Static Map in Java
Learn how to initialize a static Map in Java, including static blocks, double-brace initialization, Map.of, and best practices.
How to Install and Configure Java 8 on Mac
Learn how Java 8 is installed on macOS, why JDK paths differ, and how to verify and configure the correct Java version.
How to Iterate Over a Java Map Efficiently
Learn the most efficient ways to iterate over a Java Map, when to use entrySet, and how ordering depends on the Map implementation.
How to Iterate Through a HashMap in Java
Learn the best ways to iterate through a HashMap in Java, with examples using entrySet, keySet, values, and forEach.
How to Join Two Lists in Java Without Modifying the Originals
Learn how to join two lists in Java using JDK-only approaches, including addAll, streams, and older Java-compatible techniques.
How to Left Pad Integers with Leading Zeros in Java
Learn how to pad integers with leading zeros in Java using String.format and DecimalFormat with clear examples and common mistakes.
How to Link to a Method in JavaDoc with @link in Java
Learn how to reference methods in JavaDoc using the @link tag, including correct syntax, examples, overloads, and common mistakes.
How to Measure Method Execution Time in Java
Learn how to time method execution in Java using System.nanoTime, currentTimeMillis, and practical benchmarking tips.
How to Mock Void Methods with Mockito in Java
Learn how to mock and verify void methods with Mockito in Java, including doNothing, doThrow, doAnswer, and observer-style testing.
How to Parse JSON in Java
Learn how to parse JSON in Java and extract nested object and array values like pageName, pagePic, and post_id with clear examples.
How to Place the Cursor at the End of an EditText in Android
Learn how to move the cursor to the end of text in an Android EditText after changing its value programmatically.
How to Print a Java Array: Arrays.toString() and Arrays.deepToString()
Learn the simplest way to print Java arrays using Arrays.toString() and Arrays.deepToString() with clear examples for beginners.