'error: cannot find symbol: method rotate()

I must write a constructor that takes in a 27-letter sequence and a char that "rotates" the char sequence until the first char in the sequence matches the given char. The resulting string is then saved in the class as a field.

For example: If I were to use #GNUAHOVBIPWCJQXDKRYELSZFMT and U, I expect the constructor to give me UAHOVBIPWCJQXDKRYELSZFMT#GN.

My constructor can't find the rotate method I wrote. I had a similar problem with one of my other methods, the peek() method, so I deleted the method and used the code inside the constructor, but I want to practice good OOP principles so I don't want to do the same here.

public class Rotor{
    private String rotor;

    public Rotor(String rotor, char top){
        this.rotor = rotor;
        while(this.rotor.charAt(0)!=top){
            rotor.rotate();
        }
    }
    //rotates rotor one click clockwise
    public void rotate(){
        this.rotor = this.rotor.substring(this.rotor.length()-1, this.rotor.length()) + this.rotor.substring(0, this.rotor.length()-1);
    }

    public char peek(){
        return rotor.charAt(0);
    }
    public String toString(){
        return rotor;
    }
    public static void main(String[] args){
        Rotor rotor = new Rotor("#GNUAHOVBIPWCJQXDKRYELSZFMT", 'U');
        System.out.println(rotor.toString());
        
    }
}

    Rotor.java:7: error: cannot find symbol
                rotor.rotate();
                     ^
      symbol:   method rotate()
      location: variable rotor of type String
    1 error


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source