Java programming language features

The emergence of Java 8 for programmers, the main benefit is that it can provide more programming tools and concepts, easier to maintain a way to solve new or existing programming problems. There are two well-known improvements in Java 8: one is Lambda expression and the other is Stream.

Lambda expressions, also known as closures, allow functions to be used as parameters of a method. Using Lambda expressions can make the code more concise and compact. Important features of Lambda expressions: optional type declaration: no need to declare the parameter type, the compiler can uniformly identify the parameter value; optional parameter parentheses: one parameter does not need to define parentheses, but multiple parameters need to define parentheses; Selected braces: if the body contains a statement, you don’t need to use braces; optional return keyword: if the body has only one expression return value, the compiler will automatically return the value, and the braces need to specify the expression to return A value.

Tream is a stream, and its main function is to search and filter the collection data. Stream in Java 8 is an enhancement to the function of Collection objects. It focuses on various very convenient and efficient aggregate operations or bulk data operations on collection objects. For basic numeric types, there are currently three corresponding packaging types Stream: IntStream, LongStream, and DoubleStream. Of course, we can also use Stream, Stream >, Stream, but boxing and unboxing will be time-consuming, so the corresponding Stream is provided for these three basic numerical types.

Guess you like

Origin blog.csdn.net/xiaoxiaote/article/details/114916185