Java String array: is there a size of method?

后端 未结 11 2038
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 03:38

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.

Is there a similar

11条回答
  •  悲哀的现实
    2020-11-27 04:09

    In java there is a length field that you can use on any array to find out it's size:

        String[] s = new String[10];
        System.out.println(s.length);
    

提交回复
热议问题