[Solved] How to change what a string equals in a forloop [closed]


Just use a if condition.

if (i == 1) {
    animal = "dog";
} else if (i == 2) {
    animal = "cat";
}

Some additional comments:

  1. I would recommend using Enum instead of String.
  2. This: for(int puzzleNum = 1; puzzleNum <= NUMANIMALS; mazeNum++) looks like an infinite loop to me, as your puzzleNum doesn’t change in the loop at all.

4

solved How to change what a string equals in a forloop [closed]