-6
package com.company;

import java.io.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
     throw IOException{

        }
    }
}

Can some body help me please i follow tutorial but it show up ';' expected error

Supagon Srisawas
  • 113
  • 1
  • 1
  • 9

1 Answers1

1

If you dont't want to throw exception by using a try catch the second Methode is to do it like this:

public static void main(String[] args) throws IOException{
  //But your Code here where you Need to throw an Exception
}

The second Methode is to use a try/catch

Like this:

public static void main(String[] args){
  try{

    //Code which throws an exception
  }catch(IOException e){
     e.printstacktrace();
  }

}
user12346352
  • 176
  • 2
  • 20