I am making a program that runs a formula on the numbers inputted. The first integer in the input describes the amount of lines, or integers to be used in the formula. I am approaching this by calculating the answers and pushing them into an array. However, I am getting an array out of bounds exception in one of my for loops, and I can't figure out why.
Here is my main method:
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
int[] nums = {};
int lines = scan.nextInt();
for(int i = 0; i < lines; i++){
nums[i] = potFormula(scan.next());
}
System.out.println(nums);
}