Category: Java 8 features
-
Spring initializer with Java 8 and java 11, what is the difference among them?
The difference between downloading a Spring Boot project with Java 8 and Java 11 from the Spring Initializr lies in the version of Java that the project will be built and run with. Java 8 is an older version of Java that was released in 2014. It includes features such as lambda expressions, streams, and…
-
How to convert long to int safely in java? Math.toIntExact(long value
Math.toIntExact(long value) method, which converts a long to an int safely. This method will throw an ArithmeticException if the long value is outside of the range of int. Here’s an example code snippet that demonstrates how to use Math.toIntExact(long value): long longValue = 1234567890L;int intValue;try { intValue = Math.toIntExact(longValue);} catch (ArithmeticException e) { throw new…