It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Utils Question 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 "Utils Question" Watch "Utils Question" New topic

Utils Question

Steven Wong
Ranch Hand

Joined: Mar 07, 2002
Posts: 295

Some of the operations in the collection interfaces are optional, meaning that the
implementing class may choose not to provide a proper implementation of such an operation.
In such a case, an UnsupportedOperationException is thrown when that operation is invoked.

Question is, how do I know which of the classes provide proper implementations of which operations?

best regards,<br />Steven<br />SCJP, SCEA
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
i think all the classes in the API provide implemtations for everything.
if you make your own classes then you can choose not to implement every method in the interface.
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
Close but not 100% correct. Read the Javadoc for AbstractCollection and AbstractMap; that will give you a pretty idea of how the java.util classes are implemented. The class comments for AbstractMap in particular suggest some limitations in what might be implemented.

Reid - SCJP2 (April 2002)
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Roy very, very close.
All the classes in the API that have an implementation provide for the optional methods.

SCJP2. Please Indent your code using UBB Code
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
i stand corrected
thanks for correcting me guys.
I agree. Here's the link:
subject: Utils Question
It's not a secret anymore!