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....

>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{
             ....
         }
   }

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.

commented: Sorry jwent. My bad! I missed "I don't care" +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.