Difference between “CharSequence interface” and “CharSequence key”

这一生的挚爱 提交于 2021-01-28 07:36:27

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/62702925/difference-between-charsequence-interface-and-charsequence-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!