Why is the number of elements in the list called “size” and the length of the array called “length”?

Why is the number of elements in the list called "size" and the length of the array is called "length"?

package com.mycompany.javatest;

import java.util.*;

public class JavaTest {

    public static void main(String[] args) {

        List<String> stringList = new ArrayList<String>();
        stringList.add("one");
        stringList.add("two");
        stringList.add("three");
        System.out.println("Size of list is: " + stringList.size());

        String[] stringArray = {"one", "two", "three"};
        System.out.println("Length of array is: " + stringArray.length);
    }
}
+4
source share
1 answer

Take a look at the definition of both words from the Oxford dictionaries:

Size: The relative degree of something; overall dimensions or size; how big is something: 'Schools vary in size' Wales-sized forest

Length: Measurement or degree of something from END TO END ; the larger of the two or the largest of the three dimensions of the object: 'The delta is twenty kilometers long

" -", . END END , . , ?

, ( ), , .

+5

Source: https://habr.com/ru/post/1662627/


All Articles