Ask Question

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

+3
Answers (1)
  1. 20 November, 04:09
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers