I come from a php background and in php, there is an array_size() function which tells you how many elements in the array are used.
array_size()
(我来自php背景,在php中,有一个array_size()函数,它告诉你数组中有多少元素被使用。)
Is there a similar method for a String[] array?
String[]
(String[]数组有类似的方法吗?)
(谢谢。)
Yes, .length (property-like, not a method):
.length
(是的, .length (类似属性,不是方法):)
String[] array = new String[10]; int size = array.length;
2.1m questions
2.1m answers
60 comments
57.0k users