import java.util.Scanner;
import java.io.File;

public class Throw{

public static void main(String[] args){ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
int x = reader.nextInt();
System.out.println(x);

} }

Checked Exception

8j-except/Throw.java:11: error: unreported exception FileNotFoundException;
must be caught or declared to be thrown
      reader = new Scanner(new File(args[0]));
               ^
1 error
import java.util.Scanner;
import java.io.File;

public class Throw{

public static void main(String[] args){ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
int x = reader.nextInt();
System.out.println(x);

} }

import java.util.Scanner;
import java.io.File;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
int x = reader.nextInt();
System.out.println(x);

} }

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
int x = reader.nextInt();
System.out.println(x);

} }

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
int x = reader.nextInt();
System.out.println(x);

} }

Custom Exceptions

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
double x = reader.nextDouble();
double y = reader.nextDouble();

if(y == 0.0){
  System.out.println("Error");
}else{
  System.out.println(x / y);
}

} }

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
double x = reader.nextDouble();
double y = reader.nextDouble();

if(y == 0.0){
  <mark>System.out.println("Error");</mark>
}else{
  System.out.println(x / y);
}

} }

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
double x = reader.nextDouble();
double y = reader.nextDouble();

if(y == 0.0){
  <mark>throw new ArithmeticException("Divide by Zero!");</mark>
}else{
  System.out.println(x / y);
}

} }

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.ArithmeticException;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
double x = reader.nextDouble();
double y = reader.nextDouble();

if(y == 0.0){
  <mark>throw new ArithmeticException("Divide by Zero!");</mark>
}else{
  System.out.println(x / y);
}

} }

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.ArithmeticException;

public class Throw{

public static void main(String[] args) throws FileNotFoundException{ Scanner reader;

if(args.length > 0){
  reader = new Scanner(new File(args[0]));
}else{
  reader = new Scanner(System.in);
}
double x = reader.nextDouble();
double y = reader.nextDouble();

if(y == 0.0){
  throw new ArithmeticException("Divide by Zero!");
}else{
  System.out.println(x / y);
}

} }

"/js/highlight.pack.js"