javacharsequence

Difference between "CharSequence interface" and "CharSequence key"


Actions act = new Actions(driver);
act.keyDown(CharSequence key);

If I search online to find out what CharSequence is, I get all the information about the CharSequence interface. I can't understand what does a CharSequence interface has to do with CharSequence key used in Actions class?

Thanks


Solution

  • Take a look at the JavaDocs for CharSequence: https://docs.oracle.com/javase/8/docs/api/java/lang/CharSequence.html

    Under implementing classes, you will see

    CharBuffer, Segment, String, StringBuffer, StringBuilder
    

    So by defining Action as taking a CharSequence parameter, it means that you can use any of the CharSequence implementations above, or possibly create your own. It is a way to loosely couple classes / class dependencies and make code more reusable and durable.