This site requires JavaScript, please enable it in your browser!
Greenfoot back
Astralman
Astralman wrote ...

2016/12/11

Help with strings?

Astralman Astralman

2016/12/11

#
I want it remove "r" from green.
private String green = "GREEN";

public void board()
green = green.replaceALL ("r", "");
        System.out.println();
The code does not work, though. It says "cannot find symbol" for replaceALL. I want it to read "geen".
danpost danpost

2016/12/11

#
Astralman wrote...
I want it remove "r" from green. < Code Omitted > The code does not work, though. It says "cannot find symbol" for replaceALL. I want it to read "geen".
There is no "r" in "GREEN" -- try "R"; and the method name is 'replaceAll', not 'replaceALL'.
Astralman Astralman

2016/12/12

#
It still says "GREEN". It's not removing the R. Is this something I put inside "System.out.println()" ? I think it's called a parameter
Super_Hippo Super_Hippo

2016/12/12

#
System.out.println();
This line shouldn't give you 'GREEN' as an outcome. You should use
System.out.println(green);
Astralman Astralman

2016/12/12

#
Thanks. I was missing that parameter part
You need to login to post a reply.