Java String array: is there a size of method?

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

    There is a difference between length of String and array to clarify:

    int a[] = {1, 2, 3, 4};
    String s = "1234";
    
    a.length //gives the length of the array
    
    s.length() //gives the length of the string
    

提交回复
热议问题