Explore BrainMass

Explore BrainMass

    How to program arrays in Java

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    If you were explaining an array ti a friend who is learning Java. how would you do so?
    How would you explain how arrays are used?
    Provide at least one concrete example.

    © BrainMass Inc. brainmass.com March 4, 2021, 8:00 pm ad1c9bdddf
    https://brainmass.com/computer-science/java/program-arrays-java-137705

    Solution Preview

    You can store Java program data in variables. Each variable has:
    - An identifier,
    - A type, and
    - A scope.

    When you have closely related data of the same type and scope, it is often convenient to store it together in a data structure instead of in individual variables. The most common data structure is the array. Arrays are fixed-length structures for storing multiple values of the same type. An array implicitly extends java.lang.Object so an array is an instance of Object. But arrays are directly supported language features. This means that their performance is on par with primitives and that they have a unique syntax that is different than objects.

    Array elements:

    0 1 2
    -----------------------
    |1st | 2nd | 3rd |
    -----------------------

    * Structure of Java Arrays
    The Java array depicted above has 3 elements. Each element in an array holds a distinct value. In the figure, the number above each element shows that element's index. Elements are always referenced by their indices. The ...

    Solution Summary

    How arrays are used in Java is explained.

    $2.49

    ADVERTISEMENT