0

I am trying to replace a "." with an "X". This is eventually for a text based maze that the computer will figure out. I just want to get the first one changed, and hopefully I can figure the rest out from there. This is what I have so far.

Scanner sc = new Scanner(maze2);

public void traverseMaze(int row, int col, int handLocationX, int handLocationY) {

    for(int rowCount = 0; rowCount <=11 ; rowCount ++){
        row = rowCount;

        for(int colCount = 0; colCount <= 11; colCount++){
            col = colCount;

            if(row ==2 && col ==0){
                System.out.println(col);
                System.out.println(row);
                sc.next().replace(".", "X"); //stuck here HELP! :)
            }
        }
        System.out.println(maze2);
    }
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
pewpew
  • 700
  • 2
  • 9
  • 32

1 Answers1

0

As mentioned in the comments, String is immutable, so

sc.next().replace(".", "X"); //stuck here HELP! :)

should be something like this

String orgStr = sc.next();
String newStr = orgStr.replace(".", "X");
sinclair
  • 2,812
  • 4
  • 24
  • 53