Java Java Objects Delivering the MVP Exceptions

yige yang
yige yang
1,843 Points

what is letter + "

The code: if (misses.indexOf(letter) != -1 || hits.indexOf(letter) != -1){ throw new IllegalArgumentExceoption(letter + " has already been guessed);

1 Answer

Jason Mendez
Jason Mendez
6,630 Points

The + symbol is not a letter here. It is the symbol for concatenation. This means that the letter variable is combined with the string that follows. For example, if letter holds the value 'A' then the resulting string in the exception message would be "A has already been guessed"