Jdk1.8 has been out for a long time, but many students may not be familiar with the application of its features in Android Studio, and today we are going to do its application to this new feature in as.
First, in the case of JDK1.8, we will set this place to java1.8 in the settings of AS.
Second, add these two sentences to the Build.gradle.
That
compileoptions {
Sourcecompatibility 1.8
Targetcompatibility 1.8
}
This completes the setup work before you use it. Then we go into the important application.
So what's the nature of lambda? See below:
1. This is a click event set for a button:
What, frugality is not a lot of savings, from the previous 6 lines into 1 lines, and easier to let others understand.
2. Here is the code to open a thread
So how to change the code into a lambda style, in fact, after the setup to put the mouse on the function, Alt+enter will appear under the following interface, and then click on it.
The properties of Lambda We're going to introduce so much for the moment.
Follow the public number for more information:
Lambda expressions for jdk1.8 new features and examples of use in Android Studio