Java array.length method

后端 未结 4 719
旧时难觅i
旧时难觅i 2021-01-29 14:05

I am getting error: Undefined symbol:length.

import java.util.*;

class ssss

{

  public static void main(String args[])

    {

     int a[]={1,2,3,4};
     Sy         


        
4条回答
  •  终归单人心
    2021-01-29 14:18

    length is a public attribute not a method in array. Therefore, we access the length of array as :

    int x = a.length;
    

    and not as,

    int x = a.length();
    

提交回复
热议问题