length
is a pseudo-data member reference, and only works for (small-a) arrays (ignoring classes that you may define that implement the member).
Everything else is an object of a class, and all JDK classes that have this concept define either length()
or size()
instance methods. (I do wish they'd been consistent and picked one or the other, but that's water over the bridge.)