To check if string contains particular word

后端 未结 10 729
野的像风
野的像风 2020-12-08 04:55

So how do you check if a string has a particular word in it?

So this is my code:

a.setOnClickListener(new View.OnClickListener() {

        @Overri         


        
10条回答
  •  盖世英雄少女心
    2020-12-08 05:24

    Maybe this post is old, but I came across it and used the "wrong" usage. The best way to find a keyword is using .contains, example:

    if ( d.contains("hello")) {
                System.out.println("I found the keyword");
    }
    

提交回复
热议问题