satheesh.droid
satheesh.droid

Reputation: 31517

What is a peer class in Java?

I came across the fact StringBuffer is called peer class of String. What is a peer class?

Upvotes: 7

Views: 11622

Answers (2)

Daniel Rikowski
Daniel Rikowski

Reputation: 72514

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.

Upvotes: 15

Greenhorn
Greenhorn

Reputation: 769

As I know, peer classes are written to connect the code with the native code. See this article, http://javapapers.com/core-java/java-peer-class/.

Upvotes: 5

Related Questions