Exception in JAVA code example

 Program - 

import java.util.*;

public class urnumber{

public static void main(String[]args)

{

try{

Scanner sc = new Scanner(System.in);

System.out.println("set your number");

int a =sc.nextInt();

try{

System.out.println("enter a your number");

int p = sc.nextInt();

if (p==a)

{

System.out.println("correct number");

}

else

{

System.out.println("wrong number");

}


}catch (Exception e)

{

System.out.println("sorry ! you have entered wrong number");

}

}catch(Exception x)

{

System.out.println(" sorry ! enter a number");

}

}

}

Output 1 - 





Output 2 - 

Output 3 - 



Comments

All time Best Post

Write a program that declares a class named Person. It should have instance variables to record name, age and salary. Use new operator to create a Person object. Set and display its instance variables.

express session login system using node express mongodb

IMAGE CRUD OPERATION USING EXPRESS MONGOOSE MULTER

connect websocket to binance api and store t he true value in the db

CRUD APP WITH SORT IN NODE EXPRESS AND MONGODB

Rock-Paper-Scissor Game in Pure JavaScript

how to delete image from the folder directly from a Request (MULTER)

calculate rsi

java program for 1 to 10 print using while loop