Interested in the similarity of Java for Android and the usual, "vanilla".
2 Answers
Java and Java in Android are different things. In General, this is not so far from the truth. The trick here is this:
- In terms of syntax, Java is the same everywhere
- Compilers are also the same
- Then the differences begin, namely:
a) not all standard vanilla Java libraries are implemented in Android
b) A fundamental difference: vanilla Java is executed in a standard JVM VM, while Android is executed in a completely different Dalvik VM (in a later version of ART (Android RunTime), which uses bytecodes incompatible with the JVM - the so-called DEX bytecodes.
Technically it works like this:
- Proger writes for pure Java
- Then it compiles using the regular Java compiler (javac)
- Then the development system (usually in the background and invisible to the programmer) translates the resulting object code into the Dalvik/ART object code (the dx/d8 dock utility), attaches the necessary libraries from the Android API, and that's it.
Therefore, from the point of view of the programmer, he writes under Java, although technically it will not be quite Java...

- 203
- 3
- 12
The syntax isn't different, but many of the library calls are. That's because a tablet or phone is very different than a desktop or server environment. Your desktop probably does not use 4G, for example, or make phone calls. The User Interface for an Android phone is quite different than what you'd have in a "standard" desktop application. Also, unlike a desktop environment, Android apps only target one OS - Android.
Also, Android uses a different virtual machine than Oracle Java, and it tends to be somewhat "behind" Oracle Java in which features it supports. See this and this, for example.

- 11,977
- 56
- 49
- 78
-
A small nit: there are a few operating systems other than Android that run Android apps. Chrome OS is one example. – Ryan M Sep 25 '20 at 22:08