Ask Question
16 May, 13:39

How do you get the value of an element in an array? And how about for an ArrayList?

+5
Answers (1)
  1. 16 May, 13:48
    0
    array: a[21], b[34] etc.

    ArrayList: arr. get (12), arr. get (23)

    Explanation:

    Remember that array is a fixed size collection of values of the same datatypes. We need to provide the array size at the time of the declaration itself. Like:

    Student[]=new Student[5];

    The above is an array of five student object types.

    Similarly, we can have:

    a[] = new int[5];

    This is an array of five int type.

    And we can output the fourth student as Student[4]. name, Student[4]. marks. And in int case like a[3], a[4], etc.

    Similarly, we can get the value from ArrayList as:

    arr. get (3);

    ArrayList is a resizable array, and can be found inside java. util. ArrayList.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How do you get the value of an element in an array? And how about for an ArrayList? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers