-2

The remove.charAt() does not seem to work so I was wondering if there was something, where I input an int and it tells me what character is at that point? Again if anyone has any ideas it would be greatly appreciated. :-)

public static String removeYak(String remove)
{
    String fina1 = "";
    for(int y = 0; y < remove.length(); y++)
    {
        if(remove.toLowerCase().charAt(y) == "y")
        {
            if(remove.toLowerCase().charAt(y+1) == "a")
            {
                if(remove.toLowerCase().charAt(y+2) == "k")
                {
                    fina1 = str.substring(k+1);

                }
            }
        }
    }
    return fina1;
}
ChiefTwoPencils
  • 13,548
  • 8
  • 49
  • 75
Snare_Dragon
  • 59
  • 1
  • 11

1 Answers1

0

No, there isn't. However, you're using a correct method. The problem is in your if's. When you do something like:

String string = "abc";
char c = string.charAt(2);

You must compare character to a character, not to a string. In your if's, you write things like remove.toLowerCase().charAt(y) == "y", however, what you're looking for is remove.toLowerCase().charAt(y) == 'y'. Notice the apostrophe by the y you must use.

leonz
  • 1,107
  • 2
  • 10
  • 32