How to know if a given string is substring from another string in Java

后端 未结 16 1754
情歌与酒
情歌与酒 2020-12-20 18:58

Hi I have to compute if a given string is substring of a bigger string. For example

String str = \"Hallo my world\";
String substr = \"my\"
<
16条回答
  •  再見小時候
    2020-12-20 19:36

     String str="hello world";
            System.out.println(str.contains("world"));//true
            System.out.println(str.contains("world1"));//false
    
    • Javadoc

提交回复
热议问题