Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

will android java support lambda expression in java 8? [closed]

I understand that the "java" in a dalvik vm is different from Java se in terms of API and architecture etc. But the syntax has always been the same. (Please correct me if I am wrong)

Now the support of lambda expression in java 8 is about to be released, will android java follow it? did google or aosp promise on making dalvik consistent with java se?

UPDATE: Now as in Android 4.4 Kit Kat (API 19), Java 7 syntax has been OFFICIALLY supported.Source from android.com

like image 698
Fermat's Little Student Avatar asked Feb 11 '13 18:02

Fermat's Little Student


People also ask

Is lambda expressions introduced in Java 8?

Lambda Expressions were added in Java 8. A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.

Does Android use Java 8?

Java 8 language features are now supported by the Android build system in the javac/dx compilation path. Android Studio's Gradle plugin now desugars Java 8 class files to Java 7-compatible class files, so you can use lambdas, method references and other features of Java 8.

Which of the following is correct about Java 8 lambda?

Explanation. Both of the above options are correct. Q 5 - Which of the following is correct about Java 8 lambda expression? A - Lambda expressions are used primarily to define inline implementation of a functional interface.

Can Java 11 use lambda expressions?

From Java 11 var can also be used for lambda parameter types. Here is an example of using the Java var keyword as parameter types in a lambda expression: Function<String, String> toLowerCase = (var input) -> input. toLowerCase();


1 Answers

Android doesn't use Oracle's Java SE versions, it's based on parts of the Apache Harmony project so it doesn't even support Java 7. Harmony is not actively developed any more and won't support 1.7.

Unless Google decides to upgrade Harmony and the Android SDK to a newer Java version, there won't be any Java 7 or Java 8 features in Android - even if new features are just syntactical. They could use an alternative implementation like the OpenJDK, though I don't know of any plans for this. Some people think the use of OpenJDK is unlikely because of lawsuits between Google and Oracle.


Some features of Java 7, most notable: diamond operators, multi-catch, string switch and in Android N also some Java 8 features like lambda expressions have been implemented in Android since this answer was written. (Thanks to Ross and Stefan for mentioning it in the comments).

Google has to implement those features by their own effort and it seems that the choose to do so mostly for more popular features.

like image 130
kapex Avatar answered Oct 02 '22 10:10

kapex