When this code runs, the char variables contained in the array do not update and remain a blank space. The TicTacToe board prints in the correct format. Am I missing something obvious?
Scanner scan = new Scanner(System.in);
String pos;
boolean win = false;
char tl = ' '; char tm = ' '; char tr = ' ';
char ml = ' '; char mm = ' '; char mr = ' ';
char bl = ' '; char bm = ' '; char br = ' ';
// INITIALIZE ARRAY
char[] tic = new char[15];
tic[0] = tl; tic[1] = '|'; tic[2] = tm; tic[3] = '|'; tic[4] = tr;
tic[5] = ml; tic[6] = '|'; tic[7] = mm; tic[8] = '|'; tic[9] = mr;
tic[10] = bl; tic[11] = '|'; tic[12] = bm; tic[13] = '|'; tic[14] = br;
System.out.println("Player 1: Make your move!");
System.out.println("Choose between: TL TM TR ML MM MR BL BM BR");
pos = scan.next();
if(pos == "TL") {tl = 'X'; }
if(pos == "TM") {tm = 'X'; }
if(pos == "TR") {tr = 'X'; }
if(pos == "ML") {ml = 'X'; }
if(pos == "MM") {mm = 'X'; }
if(pos == "MR") {mr = 'X'; }
if(pos == "BL") {bl = 'X'; }
if(pos == "BM") {bm = 'X'; }
if(pos == "BR") {br = 'X'; }
System.out.println("Player 2: Make your move!");
System.out.println("Choose between: TL TM TR ML MM MR BL BM BR");
pos = scan.next();
if(pos == "TL") {tl = 'O'; }
if(pos == "TM") {tm = 'O'; }
if(pos == "TR") {tr = 'O'; }
if(pos == "ML") {ml = 'O'; }
if(pos == "MM") {mm = 'O'; }
if(pos == "MR") {mr = 'O'; }
if(pos == "BL") {bl = 'O'; }
if(pos == "BM") {bm = 'O'; }
if(pos == "BR") {br = 'O'; }
// PRINT BOARD
for(int i = 0; i <= 14; i++)
{
System.out.print(tic[i]);
if(i == 4 || i == 9)
{
System.out.println();
}
}
I was messing around and realized that I have no idea how to resolve this issue