FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaExamples/ExceptionHandling2.java at master · CMPundhir/JavaExamples · GitHub
CMPundhir
/
JavaExamples
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
7
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaExamples
/
ExceptionHandling2.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (28 loc) · 623 Bytes
Breadcrumbs
JavaExamples
/
ExceptionHandling2.java
Copy path
File metadata and controls
28 lines (28 loc) · 623 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
java
.
util
.*;
class
AgeException
extends
Exception
{
public
AgeException
(
String
msg
){
super
(
msg
);
}
}
class
ExceptionHandling2
{
private
static
void
verifyAge
(
int
age
)
throws
AgeException
{
if
(
age
<
18
){
throw
new
AgeException
(
"You can not vote"
);
}
else
{
System
.
out
.
println
(
"you can vote"
);
}
}
public
static
void
main
(
String
[]
args
){
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Enter your age : "
);
int
age
=
sc
.
nextInt
();
try
{
verifyAge
(
age
);
}
catch
(
AgeException
e
){
System
.
out
.
println
(
e
);
}
finally
{
System
.
out
.
println
(
"I am finally and i always run..."
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL