wood burning stoves
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


Win a copy of Building Microservices this week in the Design forum!
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, CCDH, CCAH 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
Sheriff

Joined: Jul 19, 2004
Posts: 7299
    
  30

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
OCAJP 7
Roel De Nijs
Sheriff

Joined: Jul 19, 2004
Posts: 7299
    
  30

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
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Can I modify the interface?
 
It's not a secret anymore!