Java arrays and strings

The length of an array is an attribute.

String [] testArray = {"this", "that"};
System.out.println(testArray.length);

The length of a string is a method.


String test="Hello there";
System.out.println(test.length());

20 views and 0 responses