Hey everyone,
I'm wondering why I can't print the values that are in the array. I'm passing an array to the method below and trying to print the result.. the compiler says that "ArrayIndexOutOfBoundsException"
What's the problem really?
public static int[] treble(int[] nums){
for (int i=0; i <= nums.length; i++){
nums[i] = 3*nums[i];
}
return nums;
}
in the main method, I have int[] array = {1,2,4};
system.out.println(treble(array));