- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathException_Class.java
More file actions
Latest commit
39 lines (35 loc) · 873 Bytes
/
Copy pathException_Class.java
File metadata and controls
39 lines (35 loc) · 873 Bytes
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
39
packagecom.company;
importjava.util.Scanner;
classMyThrextendsException
{
@Override
publicStringtoString() {
return"I am toString";
}
@Override
publicStringgetMessage() {
return"I am getMessage";
}
@Override
publicvoidprintStackTrace() {
super.printStackTrace();
}
}
publicclassException_Class {
publicstaticvoidmain(String[] args) {
Scannersc =newScanner(System.in);
System.out.println("Enter the number :");
intind=sc.nextInt();
if (ind<9)
{
try {
thrownewArithmeticException();
}
catch (Exceptione)
{
System.out.println(e.getMessage());
System.out.println(e.toString());
}
}
}
}