سؤال

I know that Java performs optimization for double ampersands in boolean expressions, such as

if(a && b)

If a is false, b is not evaluated. Does this apply to the Android platform?

هل كانت مفيدة؟

المحلول

This is a Java language rule and is converted by the compiler into appropriate Java bytecode. The Dalvik toolset then converts the bytecode into .dex files. Therefore, the Java system will apply the short-circuiting appropriately before the Android system even processes the code.

نصائح أخرى

It doesn't have any choice. It is required to do so by the Java Language Specification #15.23.

Yes, Android uses Java for its platform. It is a language rule in Java, and so it is in Android

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top