Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Sunday, June 10, 2012
Is there anything like .NET"s NotImplementedException in Java?
Is there anything like .net's NotImplementedException in java?
You could do it yourself (thats what I did) - in order to not be bothered with exception handling, you simply extend the RuntimeException, your class could look something like this:
public class NotImplementedException extends RuntimeException {
private static final long serialVersionUID = 1L;
public NotImplementedException(){} }
You could extend it to take a message - but if you use the method as I do (that is, as a reminder, that there is still something to be implemented), then usually there is no need for additional messages.
I dare say, that I only use this method, while I am in the process of developing a system, makes it easier for me to not lose track of which methods are still not implemented properly :)
Commons Lang has it: http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/NotImplementedException.html
ReplyDeleteOr you could throw a UnsupportedOperationException - http://java.sun.com/j2se/1.4.2/docs/api/java/lang/UnsupportedOperationException.html
I think the UnsupportedOperationException is what you are looking for.
ReplyDeletehttp://java.sun.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html
You could do it yourself (thats what I did) - in order to not be bothered with exception handling, you simply extend the RuntimeException, your class could look something like this:
ReplyDeletepublic class NotImplementedException extends RuntimeException {
private static final long serialVersionUID = 1L;
public NotImplementedException(){}
}
You could extend it to take a message - but if you use the method as I do (that is, as a reminder, that there is still something to be implemented), then usually there is no need for additional messages.
I dare say, that I only use this method, while I am in the process of developing a system, makes it easier for me to not lose track of which methods are still not implemented properly :)
Cheers,
Ready4Android