Questions
Java questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Java ArrayList Initialization in One Line
Learn how to initialize a Java ArrayList in one line, when to use Arrays.asList, List.of, and how mutability affects your code.
Java Class Names Explained: getSimpleName() vs getName() vs getCanonicalName()
Learn the difference between getSimpleName(), getName(), and getCanonicalName() in Java with clear examples and real use cases.
Java Date Parsing and Time Zone Transitions: Why 1 Second Becomes 353 Seconds
Learn why Java parses 1927 dates strangely in Asia/Shanghai and how time zone history affects epoch milliseconds and date math.
Java Enum Comparison: Should You Use == or equals()?
Learn how to compare Java enum values correctly using == or equals(), with examples, null safety, pitfalls, and best practices.
Java Inner Class vs Static Nested Class: Differences, Use Cases, and When to Choose Each
Learn the difference between Java inner classes and static nested classes, with examples, use cases, mistakes, and design guidance.
Java Threads: implements Runnable vs extends Thread
Learn the difference between implements Runnable and extends Thread in Java, when to use each, and why Runnable is usually preferred.
Java Unicode Escapes in Comments: Why Commented Code Can Still Execute
Learn why Java processes Unicode escapes before tokenizing, allowing sequences like \u000d in comments to affect code parsing.
Java Varargs Explained: What `String...` Means in Method Parameters
Learn what `String...` means in Java methods, how varargs work, when to use them, and how they compare to arrays.
Java instanceof and null: Do You Need a Null Check?
Learn how Java's instanceof works with null, whether a null check is needed, and how to use it safely in real code.
Optional Parameters in Java: Practical Ways to Simulate Them
Learn how optional parameters work in Java, why Java has no true optional parameters, and the common patterns to model them cleanly.
Reading a Plain Text File in Java: Common Ways and Differences
Learn how to read plain text files in Java using BufferedReader, Scanner, Files, and streams, with examples and key differences.
RecyclerView Multiple View Types in Android (Java)
Learn how to use multiple view types in an Android RecyclerView with Java using getItemViewType, ViewHolders, and practical examples.
Spring @Component vs @Repository vs @Service: What's the Difference?
Learn the difference between Spring @Component, @Repository, and @Service, including behavior, purpose, and when each annotation should be used.
StringBuilder vs String Concatenation in Java toString()
Learn when to use StringBuilder or + in Java toString(), how Java handles concatenation, and what is best for readability and performance.
StringBuilder vs StringBuffer in Java: Differences and Performance
Learn the difference between StringBuilder and StringBuffer in Java, including thread safety, performance, and when to use each one.
Testing Classes with Private Methods, Fields, and Inner Classes in Java
Learn how to test Java classes with private methods, fields, or inner classes using JUnit without changing access modifiers.
Understanding Android UserManager.isUserAGoat(): Joke API and Practical Lessons
Learn what Android UserManager.isUserAGoat() really is, why it exists, and what it teaches about reading Android APIs safely.
Understanding serialVersionUID in Java Serialization
Learn what serialVersionUID is in Java, why Serializable classes should define it, and how it prevents deserialization problems.
What "Could Not Find or Load Main Class" Means in Java
Learn what Java's "Could not find or load main class" error means, what causes it, and how to fix classpath, package, and main method issues.
What Is Apache Camel in Java? Beginner-Friendly Introduction
Learn what Apache Camel is, how it works with Java applications, and whether it runs independently or inside a server.