Questions
Java questions
Choose a question page, learn the concept, then test your understanding with a quiz.
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().
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.
How to Check If a File Exists in Java
Learn how to check whether a file exists in Java using File and Path APIs, with examples, pitfalls, and best practices for beginners.
How to Check If an Array Contains a Value in Java
Learn how to test whether a Java array contains a value using loops, Arrays.asList, streams, and best practices for beginners.
How to Check if a String Is Numeric in Java
Learn how to check whether a String is numeric in Java before parsing it, with examples, pitfalls, and practical validation patterns.
How to Check if a long Is a Perfect Square in Java
Learn how to test whether a Java long is a perfect square, including Math.sqrt, integer checks, optimizations, and common pitfalls.
How to Concatenate Two Arrays in Java
Learn how to concatenate two arrays in Java, especially String arrays, with simple examples using arrays, loops, and utility methods.
How to Configure the Server Port in Spring Boot
Learn how to change the default 8080 port in a Spring Boot application using properties, YAML, command-line args, and code.
How to Convert ArrayList<String> to String[] in Java
Learn how to convert an ArrayList<String> to a String[] in Java using toArray(), with examples, mistakes to avoid, and practical use cases.
How to Convert a Java 8 Stream to an Array
Learn how to convert a Java 8 Stream to an array using toArray(), typed arrays, examples, pitfalls, and real-world usage.
How to Convert a String to a Date in Java
Learn how to convert a String like 'January 2, 2010' to a date in Java using date parsing and modern date-time APIs.
How to Convert a String to an Enum in Java
Learn how to get an enum value from a string in Java using Enum.valueOf(), with examples, errors, validation, and best practices.
How to Convert a String to an InputStream in Java
Learn how to convert a String to an InputStream in Java using byte arrays, character encodings, and practical examples.
How to Convert a String to an int in Java
Learn how to convert a String to an int in Java using parseInt and valueOf, with examples, mistakes, and practical use cases.
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.
How to Convert an InputStream to a Byte Array in Java
Learn how to read an entire InputStream into a byte array in Java using simple patterns, examples, and common best practices.
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.
How to Create Generic Arrays in Java Safely
Learn why Java forbids generic array creation and how to create generic arrays safely using reflection and collections.
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.
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.