Reputation: 644
As a newbie in Java, I have always wondered what is meant by this fourth line of code.
String[] Songs = new String[10];
int position;
.....
if(position != -1)
What does it mean for a position in an array to be -1 in java, I know in python values such as -1 could be helpful in reversing tuples.
Upvotes: 0
Views: 318
Reputation: 15992
Well, in your example the position isn't being applied to the array. so the program is simply checking if position is not -1.
If you try to access Songs[-1] you'd get an ArrayIndexOutOfBoundsException.
Upvotes: 2