This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections Framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections Framework" Watch "Collections Framework" New topic
Author

Collections Framework

Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 528

In Khalid's last chapter (Collections), when he talks about OPTIONAL basic operations, what exactly does he mean?

i.e
boolean add(Object obj) //said to be optional
boolean remove(Object obj) //said to be optional


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
Wei-ju Wu
Ranch Hand

Joined: Feb 16, 2005
Posts: 147
Hi,

this means that these operations do not need to be fully implemented, if you have a look at the API documentation, an operation may throw UnsupportedOperationException if a concrete implementation of the List interface does not support the add(Object obj) method.

Wei-ju


"The UrlyBird catches the certificate. And he's gonna FlyByNight"<br /> <br />SCJP 1.2/5.0, SCJD, SCBCD, SCWCD, SCEA
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 528

So basically, every concrete implementation inherits them, but some do not support them. Correct?
Wei-ju Wu
Ranch Hand

Joined: Feb 16, 2005
Posts: 147
Well, I would not say "inherit", but "implements" since they are interfaces. Correct is, that they do not necessarily have to be supported.
 
Don't get me started about those stupid light bulbs.
 
subject: Collections Framework
 
It's not a secret anymore!