Is String.length() invoked for a final String?-Collection of common programming errors
str.length() is evaluated at runtime. final means that value of the reference cannot be changed. It has nothing to do with the string itself.
However, if you look into the source code of String you will see that length() returns the value of a field, so no computation takes place, the value os simply read…