Java String array: is there a size of method?

后端 未结 11 2035
佛祖请我去吃肉
佛祖请我去吃肉 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:17

    If you want a function to do this

    Object array = new String[10];
    int size = Array.getlength(array);
    

    This can be useful if you don't know what type of array you have e.g. int[], byte[] or Object[].

提交回复
热议问题