Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class notequal extends Exception
- {
- void display()
- {
- System.out.println("String are not equal");
- }
- }
- class stringequal
- {
- public static void main(String args[])
- {
- Scanner t = new Scanner(System.in);
- String s1,s2;
- System.out.println("enter 1st string");
- s1 = t.next();
- System.out.println("enter 2nd string");
- s2 = t.next();
- try
- {
- if(s1.equals(s2))
- {
- System.out.println("Strings are equal");
- }
- else
- {
- throw new notequal();
- }
- }
- catch(notequal n)
- {
- n.display();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement