In Java, when is the interface Name (which extends CharSequence) useful? Why not just use final String instead? I do not see any classes that implement Name.
Alternatively, what I am interested is the use cases of Name, CharSequence, and the String class.
It is more than just a String.
In the description of the
equalsmethod it says:So this implies that there is more to an object that implements
Namethan just its character representation. It also has to know about the implementation which created it.If you want to just compare the content you have to use
contentEquals.But you are probably not going to be creating classes using this interface yourself. It is part of the Java language model.