In Java, I’m wondering why the “length” attribute of the String class isn’t private? Isn’t it a bad practice according to encapsulation principle? Why is there no method like “getLength()” for instance?
PS: Sorry for my English, I’m still improving it.
In fact, it really is private. Maybe your confusing with the
length()method?