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 } }
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc