Questions

Java questions

Choose a question page, learn the concept, then test your understanding with a quiz.

How to Read a File into a String in Java

Learn how to read an entire file into a String in Java, including modern approaches, encoding choices, examples, and common mistakes.

javastringfilefile-io

How to Read a Large Text File Line by Line in Java

Learn how to read very large text files line by line in Java using BufferedReader and NIO, with examples, pitfalls, and best practices.

javaperformancefile-ioio

How to Remove Items While Iterating a Collection in Java Without ConcurrentModificationException

Learn why ConcurrentModificationException happens in Java and how to safely remove items from a Collection while iterating.

javacollectionsiteration

How to Round to N Decimal Places in Java with Half-Up and No Trailing Zeros

Learn how to round numbers in Java using HALF_UP and remove trailing zeros with DecimalFormat and BigDecimal.

javadecimalroundingdigits

How to Sort a Map by Value in Java

Learn how to sort a Java Map by value using comparators, streams, and LinkedHashMap, with examples, pitfalls, and a mini project.

javasortingdictionarycollections

How to Sort an ArrayList of Custom Objects by Date in Java

Learn how to sort an ArrayList of custom objects by a Date property in Java using Comparator, compare, and Collections.sort().

javasortingdatecomparator

How to Split a String in Java Using a Delimiter

Learn how to split a string in Java with a delimiter, check whether a delimiter exists, and safely access the parts with examples.

javastringsplit

How to Use java.net.URLConnection for HTTP Requests in Java

Learn how to use java.net.URLConnection and HttpURLConnection in Java for GET, POST, headers, forms, cookies, and responses.

javahttphttprequesthttpurlconnection

Including All JARs in the Java Classpath

Learn how Java classpath wildcards work, how to include all JARs in a folder, and why `lib/*.jar` may fail in some cases.

javacommand-lineclasspath

Initialize a HashSet with Values in Java

Learn concise ways to initialize a Java HashSet with values, including Arrays.asList, Set.of, mutability rules, and static final fields.

javacollectionsconstructorinitialization

Is Java Pass-by-Reference or Pass-by-Value? A Clear Beginner Guide

Learn whether Java is pass-by-reference or pass-by-value, how object references work, and why method arguments behave the way they do.

javamethodsparameter-passingpass-by-reference

Iterate Over Enum Values with a For Loop in Java

Learn how to iterate over every Java enum constant with Direction.values(), enhanced for loops, streams, and practical examples.

javaloopsfor-loopenums

JDK vs JRE in Java: Differences, Roles, and When to Use Each

Learn the difference between JDK and JRE in Java, what each includes, and when developers use one or the other in real projects.

java

JVM Heap Size Explained: What -Xms and -Xmx Mean in Java

Learn what JVM -Xms and -Xmx mean, how they control heap memory, typical defaults, and how to use them safely in Java apps.

javamemory-managementparametersjvm

Java 8 Method References: Understanding the :: Operator and Math::max

Learn how Java 8 method references work, including :: syntax, functional interfaces, and why Math::max fits IntBinaryOperator.

javajava-8method-reference

Java 8 Stream map() vs flatMap(): Differences, Examples, and Uses

Learn the difference between Java 8 Stream map() and flatMap(), including one-to-one transformation, flattening nested data, and practical examples.

javajava-8java-stream

Java Access Modifiers Explained: public, protected, package-private, and private

Learn the differences between Java access modifiers and when to use public, protected, package-private, and private in classes and inheritance.

javaprivatepublicprotected

Java Arithmetic Performance: Why Parentheses Can Benchmark Differently

Learn why equivalent Java arithmetic can benchmark differently, how JIT compilation changes code, and how to measure performance reliably.

javaperformancebenchmarkingbytecode

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.

javacollectionsarraylistinitialization

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

Page 5 of 8 - 147 questions