Never created an exception class before, so im finding it lil difficult. I have a Message class that takes a String text. Asked to me to create MessageTooBigException when text message is longer than 50 char.
So until now i have:
My Message class
public Message(String message) throws MessageTooBigException{
this.message = message;
}
My driver class
try{
Message msg_1 = new Message("Hello");
Message msg_2 = new Message("How are you today?");
Message msg_3 = new Message("Im fine. How are you?");
}catch(MessageTooBigException m){
}
My exception class
public class MessageTooBigException extends Exception {
public MessageTooBigException(String alert){
}
}
As you can see my exception class still empty. How i should move on now?
thank you


Sign In
Create Account


Back to top









