-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNestedTry.java
38 lines (30 loc) · 994 Bytes
/
NestedTry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//NINETEEN PROGRAM OF JAVA PRACTICAL
import java.util.Scanner;
public class NestedTry {
public static void main(String [] args){
Scanner sc=new Scanner (System.in);
try{
System.out.print("Enter your id:");
int a=sc.nextInt();
System.out.print("Enter your name:");
String s=sc.next();
// System.out.println("s:"+s+" "+j);
try{
if(a==0){
throw new Exception("You cannot enter default values");
}
System.out.println("Your id:"+a+"\n"+"Your name:"+s);
System.out.println("Thankyou for entering your information , have a nice day.");
}
catch(Exception e){
System.out.println(e);
}
}
catch(Exception e){
System.out.println(e);
}
finally{
sc.close();
}
}
}