If a String object is immutable (and thus obviously cannot change its length), why is length() a method, as opposed to simply being public final int lengt
String is using encapsulation to hide its internal details from you. An immutable object is still free to have mutable internal values as long as its externally visible state doesn't change. Length could be lazily computed. I encourage you to take a look as String's source code.