We can find the length of an array by using length variable.
1. length variable:-
length is a final variable applicable applicable for arrays.
length variable represent the size of an array.
example:
int [ ] x = new int [6];
System.out.println(x.length); o/p is 6 .
int [ ] x =new int [10];
System.out.println(x.length); o/p is 10 .
System.out.println(x.length());
Compile-Time Error:cannot find symbol
Symbol: method length()
But Do not Apply length( ) method here.Because length( ) is applicable for String.
2.length ( ) method:-
length( ) is a final method appicable for String Objects/
length( ) return the numbers of character present in the String.
example:
String s="javabychetan";
System.out.println(s.length()); o/p is 12
System.out.println(s.length);
Compile-Time Error:cannot find symbol
Symbol: variable length
location: class java.lang.String