wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 519

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: 519

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
 
Similar Threads
equals()
Why are Abstract classes with all concrete methods allowed?
check if ID already exists
Collections question
StringBuffer and equals() method overriding