开发者

How to use CharSequence

开发者 https://www.devze.com 2023-02-14 13:20 出处:网络
Hey i\'m having some trouble understa开发者_JAVA技巧nding CharSequence. I think this will be the perfect method to help with my hw but im having trouble understanding how to use it.

Hey i'm having some trouble understa开发者_JAVA技巧nding CharSequence.

I think this will be the perfect method to help with my hw but im having trouble understanding how to use it.

How do i make the sequence < /p> comes up.

This is what i have so far:

String s = "</p>";
char c;

while(reads.hasNext()){
c = reads.next();
    s = "" + c;
    if (inputPath.contains(?)) {
    // how do i make it return true if it contains < /p>
    }
}


Assuming you are talking about java.lang.CharSequence, it is an interface, and is the parent for String, StringBuilder, and StringBuffer (and some other things).

It looks like you are more looking to see if the input you have so fat has, or contains a given string (</p>). To do that you could make use of the Pattern class or the String.equals or String.indexOf method (or the StringBuilder version).


You can test that one String contains another using indexOf():

if (inputPath.indexOf("< /p>") != -1) {
    // inputPath contains "< /p>" somewhere in it
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号