Sign in to follow this  
musafir2007

Basic Java Help - Comparing Chars?!

Recommended Posts

Why wouldn't this work?!?!! It says.. charAt(int) in java.lang.String cannot be applied to (i) Why?
public void speakTurtle(String actions)
{
     for (int i=0; i<actions.length()); i++)
     {
        if (actions.charAt(i)=='F')//Gives me error at i here..
        {
            System.out.println ("Works!");
        }
     }
}



Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this