Ask Question
13 April, 23:48

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

+4
Answers (1)
  1. 14 April, 01:04
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers