0

using exception try, catch and finally derive a program that accepts any 10 letter string. if the string is greater than 10, display an error message; if string has no vowel display an error message else display only all vowels. can u help me for the java code of this program? plss....

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by __avd
0

>can u help me for the java code of this program?

class MyException extends Exception {
         public MyException() { }
         public MyException(String msg) { super(msg); }
    }
   ...
   void testMethod() throws MyException {
           ....
           if(lengthExceed)
                   throw new MyException("put_your_message");
           ....
           if(!containsVowels)
                   throw new MyException("put_your_message");
   }

   void testException(){
      try{
            ...
            testMethod();
            ...
          }catch(MyException ex){
              ....
          }catch(Exception ex) {
              ....
          }finally{
             ....
         }
   }
1

Why do you want to use try catch and finally block here? Do you have any user defined exception classes for this purpose?

idiot. It's a homework kiddo assignment. It's teacher told it to do it like that, and you of course are too stupid to comprehend that.

Votes + Comments
Sorry jwent. My bad! I missed "I don't care"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.