Why is CharSequence from the Java API an interface? What is the significance of this interface?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s just refactored from any existing implementations. One of the benefits is that you can “widen” the input whenever you actually only need one of its methods.
So instead of for example
you can have
so that you can pass
String,CharBuffer,StringBuilder,StringBufferand otherCharSequenceimplementations in.This fact has however nothing to do with
java.util.Regex, it only takes benefit of it =)