Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Android's Java version relate to a Java SE version?

I am constantly wondering how the Java version used for Android development relates to a Java SE version. For example, I was reading today about "Type Inference and Generic Methods" which is a feature added in Java SE 7. I wonder to myself, "Can I use this in Android code?"

Of course I could type the code into an Android project and see if it compiles, but I'd be happier to have some kind of mapping in my head.

I've tried Googling for this info, checking the Android docs, etc, but can't find an answer.

Edit: I'm more interested in language features, e.g. how does the Android Java syntax version relate to Java SE syntax.

like image 296
jfritz42 Avatar asked Sep 23 '11 22:09

jfritz42


People also ask

Is Java for Android the same as Java?

What is the difference between Android and Java? Java is a programming language, while Android is a mobile phone platform. Android development is java-based (most of the times), because a large portion of Java libraries is supported in Android.

Is Android Studio Java different?

Yes it is. The syntax is exactly the same and you can use the same methods that are available in Java SE. Android has its own SDK (Software Development Kit) which is specific Java classes and methods for Android, i.e. dealing with click events and user interface.

What version of Java does Android use?

Current tools can support all Java 7 and a few Java 8 features on all versions of Android. Additional Java 8 features are only available on API Level 24+, usually because they rely upon certain classes that were only added to the Android SDK at that point.

What is Java SE version?

Java SE 18.0. 2.1 is the latest release of Java SE Platform.

What version of Java is used in Android Studio?

In terms of language features (e.g., lambda expressions), quoting the documentation: Android Studio 3.0 and later supports all Java 7 language features and a subset of Java 8 language features that vary by platform version Here, "Android Studio" is really referring to the build tools that compile your source code and create the Dalvik bytecode.

Does Android 4 0 support Java 7?

After some research I found out that ReflectiveOperationException is not available before Java 7 and so, apparently, Android 4.0 does not support Java 7. This makes me wonder: Is there an overview which clearly shows which Android versions come with which Java version? e.g. how can I find out the first Android version that supports Java 7?

Is there a way to map Java 8 to Android version?

Additional Java 8 features are only available on API Level 24+, usually because they rely upon certain classes that were only added to the Android SDK at that point. But your concern seems to be with classes and methods, in which case there is no simple mapping of any Java version to any Android version.

What versions of Java are supported by current tools?

Current tools can support all Java 7 and a few Java 8 features on all versions of Android. Additional Java 8 features are only available on API Level 24+, usually because they rely upon certain classes that were only added to the Android SDK at that point.


1 Answers

Android's version doesn't directly relate to Java SE, although it uses a subset of Apache Harmony's SE 6 libraries and tools. It will be up to the Android team to decide if & when to support/require the SE 7 version of Harmony.

Edit It looks like as of KitKat Android supports Java SE 7 language features. See the comments below.

like image 119
pents90 Avatar answered Oct 03 '22 09:10

pents90