I am trying to make a really simple Tic-Tac-Toe game. I have stored values of "X" and "O" in a 0-8 ArrayList (3x3 square, essentially). I can do the following for each instance of a winning situation:
if ((newBoard().get(0)).equals("X") &&
(newBoard().get(1)).equals("X") &&
(newBoard().get(2)).equals("X")){
System.out.println("Player-X has won!");
return true;
However, this is going to take a TON of code! I thought about creating new ArrayLists that contain the situations in which "X" has won (3-in-roe) and then copy and paste, replace "X" with "O", then compare these with the current ArrayList board that the user is 'interacting with.' That's all good, but I don't know how to compare them. I looked at the API, but I couldn't find anything that could do what I want, which is to compare to ArrayLists, but only for the specified indexes.
Anything pertaining to making this situation a bit smaller, code-wise, will be greatly appreciated. Thanks!