java - contains method of String is not working properly -


i have 1 question not able solve .

  public static  void main(string [] arg) {              string description = "this time $fb highest priority";          list<string> list = new arraylist<string>();          list.add("$fb");          list.add("$f");          for(string s : list) {            if(description.contains(s)) {               system.out.println(s);            }           } } 

the out put getting $fb , $f dummy string contains 1 string of list .. other method give exact match ?

it looks want see if word contained. can this:

set<string> words = new hashset<string>(arrays.aslist(description.split(" ")));  ... words.contains(s) ... 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -