Can someone please help me understand why I'm getting an exception here?
Welcome to inventory managment.
How many items?
Enter item name: Homo
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
Java Result: 1
BUILD SUCCESSFUL (total time: 16 seconds)
It was intended to be a variable for the array, initially line 37 used an i for the count variable, that's where I got the error. This code is the result of me trying to tweak it to get it to work. When I switched the count variable to a in line 37 I got an error in the array variable on line 40.
I found 2 issues in your program
The first one:
I believe that You are initializing all the above array of zero length. count is zero and hence all the above arrays will have length zero. Now count does not count for array indices any more
You are taking input and storing it in count which overwrites the previous data.
The second one:
either keep "i" or keep "a". If you think a is for counter replace i with a or vice versa whichever suits you.
The ArrayIndexOutOfBoundsException is thrown because in line no 40 you are accessing something that does not actually exist. I mean anything like productName or productname does not exisst since you initialized the array to be of zero length.