Checking enum value index

weireeTer

New Member
I having an issue while checking the index of an enums value, I have an enum with a varargs integer, if that integer is greater than one and is a replaceable item, then when I get the next index I increment it by one. But, when there is not another integer after the increment, the game crashes, I've been trying to come up with a solution to this for the past half hour or so, I can't seem to check if its the last index within the enum. I know this is a very localized question but I need some help.The code:\[code\]private int getNextId(Food food, int id) { if (food.getType().equals(REPLACE)) { for (int i = 0; i < food.getIds().length; i++) { if (food.getIds() == id) { return food.getIds()[i + 1]; } } } return -1;}\[/code\]Oh and another note, I have tried for checking if it's -1 or 0, but like I said I can't seem to figure it out. Thanks in advanced.
 
Back
Top