length vs. length()

length: meant for array to find the length of an array .
length(): meant for String to find the length of a string.
Example: ArrayTest.java

class ArrayTest {
 public static void main(String[] args) {
  String[] s = {
   "s",
   "ss",
   "sss"
  };
  System.out.println(s.length); //3
  System.out.println(s.length()); //compile time error
  System.out.println(s[0].length); //compile time error
  System.out.println(s[0].length()); //1
 }
}
e.printStackTrace();
}
return m;
}

 


Output
langth vs length()

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 9439202111  |  9658317757  |  0674-2361252

Comment