Java 8 Features -
- Lambda Expressions - One of the major Java 8 feature is Lambda Expression. Lambda expressions are a way to write the code smartly. They operate with or without parameters, they are more useful with collections for iterating and manipulating the data.
- () -> expresion
- (parameters) -> expresion
- (parameters) -> { set of statements }
Example -
- () -> system.out.println("Lambda expression");
- (a, b) -> a+b;
- (a, b) -> {
system.out.println("c = "+c);
}
- Streams - Another major feature of Java 8 is stream api which enables us to handle and process the data very efficiently.
- Default & Static Methods - Java 8 enables us to use non abstract methods in an interface i.e, we can now write the implementation of a method in an interface by declaring it default or static.
- Functional Interface - A Functional Interface is an interface with only one abstract method. @FunctionalInterface annotation is used to make sure that only one abstract method is used in the interface. If more than one abstract method is added, then compiler gives an error message. If default and static methods are not abstract then they can be a part of functional interface.
- DateTime API - Java 8 introduces the new date time api, which enables us to easily handle the date and time features.
- LocalDate - Used to get only date.
- LocalTime - Used to access only time.
- LocalDateTime - Used to access date and time together.
- Instant - Used to access date and time based on timezone.
Using the inbuilt now() function with the above classes we can get current date and time -
LocalDate localDate = LocalDate.now();
LocalTime localTime = LocalTime.now();
LocalDateTime localDateTime = LocalDateTime.now();
Instant instant = Instant.now();
merit casino【WG】lucky bonus
ReplyDelete➤【 Wallets】slot games,lucky 1xbet bonus,lucky bonus,lucky bonus,lucky bonus,lucky bonus,lucky 메리트카지노총판 bonus,lucky bonus,lucky bonus,lucky 카지노 bonus,lucky