In a Java program running on the JVM, primitive data types have guaranteed bit size. e.g.
byte 8-bit
short 16-bit
int 32-bit
et cetera.
Are these bit sizes guaranteed on Android as well? I’ve been looking for documentation on Android Developers for confirmation. Any links to documentation are appreciated.
Yes they are. Otherwise, Java libraries would not be portable to Android.
And the documentation says so …
Reference: http://developer.android.com/guide/components/fundamentals.html
which says in the first sentence:
The Java programming language explicitly specifies the sizes and semantics of all primitive types. If the sizes were different on an Android implementation, that implementation would be in fundamental violation of the (relevant) Java language specification … and therefore NOT JAVA.