0
import java.util.*;
public class Windchill {
    public static void main(String[]args)
    {
        double t=Double.parseDouble(args[0]);
        double v=Double.parseDouble(args[1]);
        double w=35.74+0.6215*t+(0.4275*t-35.75)*Math.pow(v, 0.16);
        System.out.println("Windchill =" + w);
        }
        
    }

Keep getting this error and unsure why can someone help:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at Windchill.main(Windchill.java:5)
viveke
  • 1

1 Answers1

1

This happens because you're trying to get a value from an empty String[].

On this line

double t = Double.parseDouble(args[0]);

You try to get args[0] but are you giving any args when you run the program? Check this link to see how to do it.

If you're not, you're trying to get 1 item from an array with size = 0 which is more than it has, hence ArrayIndexOutOfBoundsException

Mario Codes
  • 689
  • 8
  • 15