I came across the fact StringBuffer
is called peer class of String
. What is a peer class?
The purpose of the abstract Peer class is to provide a common base class definition that can be shared by derived classes, such as PeerNearMe and PeerContact. It cannot be directly constructed, since it is abstract.
A native peer is a native object to which a normal object delegates via native methods. Because a native peer is not a normal object, the garbage collector doesn't know about it and can't reclaim it when its Java peer is reclaimed.
First of all: You have to be careful with the term "peer class", because in Java it has a distinct meaning: Peer classes are "interfaces" to native classes. (a C++ class for example) (See the other anwsers for details)
In your case the term seems not to be used in that specific context!
Whoever called StringBuffer
a peer class to String
obviously used that word in a general sense. In a way StringBuffer
and String
are related and both of them can be used for similar purposes. I guess in some use cases they could be considered peers in the broader sense of the word.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With