Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

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
    }
}

About the Author



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






 PreviousNext