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
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();
@TheLostMind answer
change
int x = a.length();
to
int x = a.length;
length() is not a valid method. So you can try like this
class ssss
{
public static void main(String args[])
{
int a[]={1,2,3,4};
System.out.println(a[1]);
int x = a.length;
System.out.println(x);
}
}
length
is a field for arrays and not a method. Use a.length