Unreported exception java.io.IOException when compiling Java code

后端 未结 2 354
余生分开走
余生分开走 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:25

    Change your main method declaration to:

    public static void main(String[] args) throws IOException

    In Java, each method A calling another method B, must declare all the exceptions
    which B can throw (unless they are descendants of RuntimeException or unless A
    is catching and processing them explicitly in a try-catch block).

    In your case A is main, B is printFile.

提交回复
热议问题