Answer the question
In order to leave comments, you need to log in
Java as a Language: Are there any differences between Android development and Java SE/EE (February 2015)?
Hello!
As part of the task of learning how to create applications for Android, I asked myself to master the required tools, primarily the Java language itself.
After reading an introductory book on Java, focused primarily on the use of Java SE, I noticed that the language is actively developing, and various new constructs are constantly appearing in it. For example, Java 8 introduced lambdas.
In this regard, the question is: exactly as a language , that is, a set of syntax and grammar, as well as the programming structures that they describe, is the "canonical" Java from Oracle identical to the language in which Android programs are written? Relatively speaking, all these generics, lambdas and annotations, are they available to Android developers in the same form as "normal"
A separate issue is language versioning. As far as I understand, in "normal" Java everything depends on the JVM version, that is, when writing code, the available syntax is determined by the version of the virtual machine on which it will be executed.
What about Android? Does it all depend on the OS version? Then, for example, if I create an application that supports Android starting from version 2.1, then not only the API that existed at that time is available to me, but also the syntax of the language that was relevant at that time, that is, in my example, without lambdas ? Or do the restrictions apply only to the API, and the compiler automatically generates bytecode from the new source text, which even the old version of Dalvik can understand?
I would be grateful to anyone who can shed some light on this issue.
Answer the question
In order to leave comments, you need to log in
Inspired by the previous answers and noticing some inconsistencies in the opinions of their authors, he went on his own search. And here's what I found.
Is it possible to use Java 8 for Android development? is a question on StackOverflow dated April 2014. The general idea of the answers is as follows:
Android does not support java8, moreover, android itself runs its own version of jvm ─ dalvik, and in android l art (in some earlier it was possible to select a virtual machine on the device, in l they abandoned dalvik )
almost all sugar for android is not available, but if you really need it, you can look towards kotlin
The last statement is correct.
All the same. The language version doesn't matter. The difference between android versions is the API. To support very old versions of android with modern features, the Support Library is used.
Let's say you were developing in Java 6. Then you upgraded to Java 8. You rewrite the code in Java 8 (optimizing only the features and operation of Java, not Android) and everything works fine.
That is, how the language is exactly "canonical" from Oracle. But Android seems to only work with Java 6. (correct in the comments if wrong).
In structure, it has a similarity to Java EE (you can immediately notice this), but this is the structure of an Android project.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question