File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Peer Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Peer Classes" Watch "Peer Classes" New topic

Peer Classes

jyothi abraham
Ranch Hand

Joined: Aug 14, 2001
Posts: 46
What is peer classes.
I know in java.awt.Component class there are peer classes.
But i came to know String and StringBuffer classes are peer
classes because they come at same level of heirarchy(and so
if we have two constructors for a class that takes String in one and StringBuffer in other and if we try to invoke an object
with string argument(at constructor) ,at o/p we get "constructors are ambigous" error).
So what all Peers are there behaves in this way?
Thanking You,
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Jyothi,
My definition of peer is not the same as you have mentioned.
You must be aware that java.awt.* package API was developed in scant 21 days.The reason for such a rapid development is due to the peer concept, which Sun used for developing this API.
For example, to develop some component like say Window, they did not try and define the class by itself.Instead, the class Window of AWT API invoked a call to its Operating System peer class to display the Window.These Operating System classes which are invoked, when we instantiate Java components like Frames, Windows, Buttons, etc. are called peers.
Hope this helps,
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
jyothi abraham
Ranch Hand

Joined: Aug 14, 2001
Posts: 46
Hai Sandeep,
thanx,I understood that point.
But why String and StringBuffer class behaves in that way,no
matter peers or nonpeers.Any other classes display the same
I agree. Here's the link:
subject: Peer Classes
It's not a secret anymore!