Explore BrainMass
Share

Explore BrainMass

    Methods for Allocating Memory for an Array

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

    Describe some of the methods for allocating memory for an array and describe methods for initializing an array. Please include example code that does this.

    © BrainMass Inc. brainmass.com October 9, 2019, 7:05 pm ad1c9bdddf
    https://brainmass.com/computer-science/memory/methods-allocating-memory-array-107675

    Solution Preview

    In Java, an array variable is declared the same way that any Java variable is declared. It has a type and a valid Java identifier. The type is the type of the elements contained in the array. The [] notation is used to denote that the variable is an array. Some examples:

    int[] counts;
    String[] names;
    int[][] matrix; //this is an array of arrays

    Once an array variable has been declared, memory can be allocated to it. This is done with the new operator, which ...

    Solution Summary

    Methods for allocating memory for an array and describe methods for initializing an array are featured.

    $2.19