ArticleslgStudy

computer science

Comparison of Java and Android API

Comparison of Java and Android API is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Comparison of Java and Android API rather than just read about it. In short: This article compares the application programming interfaces (APIs) and virtual machines (VMs) of the programming language Java and operating system Android. While most Android applications are written in Java-like language, there are some differences between the Java API and the Android API, and Android does not run Java bytecode by a traditional Java virtual machine (JVM), but instead by a Dalvik virtual machine i…

Key takeaways

  • Comparison of Java and Android API belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Comparison of Java and Android API to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Comparison of Java and Android API from memory before moving on to harder problems.

Reference excerpt

This article compares the application programming interfaces (APIs) and virtual machines (VMs) of the programming language Java and operating system Android. While most Android applications are written in Java-like language, there are some differences between the Java API and the Android API, and Android does not run Java bytecode by a traditional Java virtual machine (JVM), but instead by a Dalvik virtual machine in older versions of Android, and an Android Runtime (ART) in newer versions, that compile the same code that Dalvik runs to Executable and Linkable Format (ELF) executables containing machine code. Java bytecode in Java Archive (JAR) files is not executed by Android devices. Instead, Java classes are compiled into an android bytecode (dex bytecode) format and run on Dalvik (or compiled version thereof with newer ART), a specialized virtual machine (VM) designed for Android. Unlike Java VMs, which are stack machines (stack-based architecture), the Dalvik VM is a register machine (register-based architecture). Dalvik has some traits that differentiate it from other standard VMs:

The VM was designed to use less space. The constant pool has been modified to use only 32-bit indexes to simplify the interpreter. Standard Java bytecode executes 8-bit stack instructions. Local variables must be copied to or from the operand stack by separate instructions. Dalvik instead uses its own 16-bit instruction set that works directly on local variables. The local variable is commonly picked by a 4-bit virtual register field. Because the bytecode loaded by the Dalvik virtual machine is not Java bytecode and due to the way Dalvik loads classes, it is impossible to load library packages as jar files. A different procedure must be used to load Android libraries, in which the content of the underlying dex file must be copied in the application private internal storage area before it is loaded.

System properties As is the case for the Java SE class System, the Android System class allows retrieving system properties. However, some mandatory properties defined with the Java virtual machine have no meaning or a different meaning on Android. For example:

java.version property returns 0 because it is not used on Android. java.specification.version invariably returns 0.9 independently of the version of Android used. java.class.version invariably returns 50 independently of the version of Android used. user.dir has a different meaning on Android. user.home and user.name properties do not exist on Android.

Class library Current versions of Android use the latest Java language and its libraries (but not full graphical user interface (GUI) frameworks), not the Apache Harmony Java implementation, that older versions used. Java 8 source code that works in latest version of Android, can be made to work in older versions of Android.

java.lang package By default, the default output stream System.out and System.err do not output anything, and developers are encouraged to use the Log class, which logs Strings on the LogCat tool. This has changed at least from HoneyComb, and they now output to the log console also.

Graphics and widget library Android does not use the Abstract Window Toolkit nor the Swing library. User interfaces are built using View objects. Android uses a framework similar to Swing, based on Views rather than JComponents. However, Android widgets are not JavaBeans: the Android application Context must be provided to the widget at creation.

Look and feel Android widget library does not support a pluggable look and feel architecture. The look and feel of Android widgets must be embedded in the widgets. However, a limited ability exists to set styles and themes for an application.

Layout manager Contrary to Swing where layout managers can be applied to any container widget, Android layout behavior is encoded in the containers.

java.beans package Android includes only a small subset of the java.beans package (PropertyChangeEvent and related classes).

See also Android (operating system) Java (programming language)

References

Worked examples

Example 1 — a first encounter with Comparison of Java and Android API

Start with the simplest possible case. Write down what Comparison of Java and Android API claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Comparison of Java and Android API before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Comparison of Java and Android API ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Comparison of Java and Android API

In research
Comparison of Java and Android API appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Comparison of Java and Android API in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Comparison of Java and Android API is common in secondary-school and first-year university syllabi. It links to neighbouring topics Android (operating system), Computing comparisons, Java (programming language), so understanding it makes those chapters shorter.
In everyday life
Look for Comparison of Java and Android API outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Comparison of Java and Android API” →

How to study Comparison of Java and Android API in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Comparison of Java and Android API means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Comparison of Java and Android API out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Comparison of Java and Android API in simple terms?

This article compares the application programming interfaces (APIs) and virtual machines (VMs) of the programming language Java and operating system Android. While most Android applications are written in Java-like language, there are some differences between the Java API and the Android API, and A…

Why does Comparison of Java and Android API matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Comparison of Java and Android API?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Comparison of Java and Android API.

Tags

  • Android (operating system)
  • Computing comparisons
  • Java (programming language)

Keep exploring