Find a complete word in a string java

前端 未结 9 2170
伪装坚强ぢ
伪装坚强ぢ 2021-01-16 06:52

I am writing a piece of code in which i have to find only complete words for example if i have

String str = \"today is tuesday\";

and I\'m

9条回答
  •  死守一世寂寞
    2021-01-16 07:00

    String str = "today is tuesday";
    
    StringTokenizer stringTokenizer = new StringTokenizer(str);
    
    bool exists = false;
    
    while (stringTokenizer.hasMoreTokens()) {
        if (stringTokenizer.nextToken().equals("t")) {
            exists = true;
            break;
        }
    }
    

提交回复
热议问题