Questions

Java questions

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

How to Convert an Array to an ArrayList in Java

Learn how to convert an array to an ArrayList in Java, including syntax, examples, common mistakes, and real project usage.

javaarraysarraylisttype-conversion

How to Convert an InputStream to a String in Java

Learn how to read a Java InputStream into a String safely using charset-aware techniques, examples, pitfalls, and best practices.

javastringiostream

How to Create and Understand a Memory Leak in Java

Learn what a Java memory leak is, how it happens, simple examples, common causes, and how developers prevent leaks in real code.

javamemorymemory-leaks

How to Create and Write to a File in Java

Learn the simplest ways to create and write text files in Java using FileWriter, BufferedWriter, and Files.write examples.

javafile-io

How to Declare and Initialize an Array in Java

Learn how to declare and initialize arrays in Java with simple examples, syntax, common mistakes, and practical use cases.

javaarrays

How to Fix "No Main Manifest Attribute" in a JAR File (Java)

Learn what "no main manifest attribute" means in Java, why it happens, and how to inspect or run a JAR correctly.

javajarmanifestprogram-entry-point

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.

javaandroidandroid-networkingnetworkonmainthread

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.

javajvmincompatibilityunsupported-class-version

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.

javastringrandomalphanumeric

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.

javajava-io

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.

javadictionarycollectionsinitialization

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.

javadictionarycollectionsiteration

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.

javaloopshashmapiteration

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.

javajsonparsing

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.

javaarraysprintingtostring

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 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 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

Page 2 of 4 - 69 questions