Unreported exception java.io.IOException when compiling Java code

后端 未结 2 356
余生分开走
余生分开走 2021-01-26 01:36

I am experiencing a problem with this code:

public class gravityv1 {
    public static double[] calculategravity(double[] mass, int[] diameter) {
        double[         


        
2条回答
  •  花落未央
    2021-01-26 02:21

    You need a try-catch block in your main method around all methods that throw an IOException:

    try {
        printFile(gravity);
    } catch (IOException ex) {
        // handle exception here
    }
    

    Include all methods that have throws IOException after the signature.

提交回复
热议问题