File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Can I modify the interface? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Can I modify the interface?" Watch "Can I modify the interface?" New topic
Author

Can I modify the interface?

David Kachen
Ranch Hand

Joined: May 20, 2010
Posts: 42
Hi all,

I want to add some methods throws IllegalArgumentException. In the implementation, I plan to check the parameters and if with them that something is wrong, I will throw IllegalArgumentException. It is admissible?

Best Regards..
Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

Hi David,


Yes, you can do that, but there is no need to change the signature of the Sun interface methods,
since IllegalArgumentException extends RuntimeException and therefore it is NOT a checked Exception.

Hope this helps,


Carlos.


SCSA, OCA, SCJP 5.0, SCJD http://www.linkedin.com/in/carlosamorillo
David Kachen
Ranch Hand

Joined: May 20, 2010
Posts: 42
Carlos, you are right..
But I mean a javadoc. In the javadoc I need to list all possible situations.
If I pre-suppose that IllegalArgumentException may be thrown, I need to describe it in the javadoc.
Such changes are allowed?
Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

No, there is no need.
You only document checked exceptions.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

No changes are allowed to Sun's interface! Creating your own interface and redefining each method could be an option (and that's what I did)



SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

Carlos Morillo wrote:You only document checked exceptions.

I also documented in javadoc the unchecked exceptions, although I didn't mention them in the method signatures. Just like for example the compareTo method from class Date.
David Kachen
Ranch Hand

Joined: May 20, 2010
Posts: 42
I'm not going to change the method signature, I just want to competently write Javadoc.
David Kachen
Ranch Hand

Joined: May 20, 2010
Posts: 42
Roel, I understood you.

Thank you all
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can I modify the interface?