2

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.

2 Answers 2

6

Are these bit sizes guaranteed on Android as well?

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:

Android applications are written in the Java programming language.

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.

Sign up to request clarification or add additional context in comments.

Comments

1

You can confirm this by checking the wrapper classes, e.g., java.lang.Byte confirms that a Byte is 8 bits, Character is 16, and Integer is 32.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.