jain12

Exception handling doubt 2

Jun 5th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1.  
  2.  class MyException extends Exception{
  3.    MyException(String S){
  4.       super(S);
  5.        }
  6.    }
  7.  
  8.  class Exc1{                            //o/p sahi nahi aa raha
  9.   public static void main(String args[]){
  10.     if(args[0]=="Hello"){
  11.         System.out.println("String is right");
  12.         }
  13.     else{
  14.        try{
  15.             throw new MyException("invalid string");
  16.              }
  17.        catch(MyException e){
  18.             e.getMessage();  
  19.            }
  20.         }
  21.      }
  22.   }
Add Comment
Please, Sign In to add comment