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.
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.
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.
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.
Java SE 18.0. 2.1 is the latest release of Java SE Platform.
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.
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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With