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().

javaconstructor

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.

javamacos

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.

javafile-ioiofile-exists

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.

javaarrays

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.

javastringnumeric

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.

javamathoptimizationperfect-square

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.

javaarraysconcatenationaddition

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.

javaspring-bootserverport

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.

javaarraysstringarraylist

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.

javaarraysjava-8java-stream

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.

javastringdatetime

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.

javaenums

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.

javastringtype-conversioninputstream

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.

javastringtype-conversioninteger

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

javaarraysinputstream

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 Generic Arrays in Java Safely

Learn why Java forbids generic array creation and how to create generic arrays safely using reflection and collections.

javaarraysgenericsreflection

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

Page 2 of 6 - 117 questions