first commit
This commit is contained in:
21
TryCatch.java
Normal file
21
TryCatch.java
Normal file
@@ -0,0 +1,21 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
class TryCatch
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
//lets divide by 0 LOL
|
||||
try {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
System.out.println("Enter a number to divide:");
|
||||
int x = scanner.nextInt();
|
||||
|
||||
System.out.println("Enter a number to divide by:");
|
||||
int y = scanner.nextInt();
|
||||
int z = x/y;
|
||||
}
|
||||
catch(ArithmeticException e)
|
||||
{
|
||||
System.out.println("1 over zero equals infinity -Ggsya");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user