Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
30 lines (23 loc) · 706 Bytes

File metadata and controls

30 lines (23 loc) · 706 Bytes
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
29
30
package com.tutorial.exceptionhandling;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
String s = "smit";
try {
divide(5,1);
login(s);
System.out.print("Login Successful");
} catch (DivideByZeroException e) {
e.printStackTrace();
}catch (LoginException e) {
System.err.println(e.getMessage(s));
}
}
public static void divide(int num, int den) throws DivideByZeroException{
if(den == 0) throw new DivideByZeroException("Denominator cannot be Zero");
else System.out.println(num/den);
}
public static void login(String str) throws LoginException{
if(!str.equals("secret")) throw new LoginException("Login Failed");
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.