Java 8 Interview Questions(+ Answers) Source: (baeldung.com) A set of popular Java8-related interview questions and of course answers. Outline: A set of practical Collections-related Java interview questions Q2. What Is a…
Java get current date
java.time.format.DateTimeFormatter java.text.SimpleDateFormat java.time.LocalDate java.time.LocalTime java.time.LocalDateTime java.time.Clock java.util.Date Example 2 java.sql.Date
Java primitive data types
Java has eight built-in data types, referred to as the Java primitive types. boolean Type: true or false Example: byte Type: 8-bit integral value Example: short Type: 16-bit integral value…
Java null pointer exception
NullPointerException is a runtime exception and it is thrown when the application tries to use an object reference that has a null value. Let`s look to the Oracle doc one…
Java Array to List
Converting array to list in Java But then if you do something like this: you get java.lang.UnsupportedOperationException. So for some cases you even need this: Explicit type argument Integer can be…
Java Try With Resources
The Java try with resources construct automatically close resources like a Java InputStream or a JDBC Connection. The resources we declare in the try block should extend the java.lang.AutoCloseable class. It looks like a…
Java write to file
Write With FileWriter Write With BufferedWriter The advantage of using BufferedWriter is that it writes text to a character-output stream, buffering characters so as to provide for the efficient writing (better performance)…
SPRING BOOT COMMANDLINERUNNER
Spring Boot CommandLineRunner example:
HOW TO CONVERT JAVA INT TO STRING
1. Converting Integer to String in Java using Integer.toString(int) Output 2. Converting Integer to String in Java using String.valueOf(int) Output 3. Converting Integer to String in Java using String.format() Output 4. Converting Integer…
STRING TO JSON IN JAVA
JSON String example: Converting JSON String to Java object: The Gson is an open-source library to deal with JSON in Java Java Object: