I am experiencing a problem with this code:
public class gravityv1 {
public static double[] calculategravity(double[] mass, int[] diameter) {
double[
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.
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
.