java - How to match a string to another string in an array list and print the match? -


ok, here question have. i'm trying allow user search contact list matching contact "lastname, email, , zipcode" i've tried using "matches" , "equals" function, boolean if have match, print out string/contact match. however, doesn't print out anything. using wrong function match contacts? match function found in contactlist.java below under method searchemail.

mainactions.java

    case 3:         // read in last name here         string userstringlastname;         system.out.println("enter last name search for: ");         userstringlastname = reader.next();         list.searchlastname(userstringlastname);         break; 

contactlist.java

/**  *   * @param userstringlastname  */ public void searchlastname(string userstringlastname) {     // search last name      (int = 0; < contacts.size(); i++) {         contact c = contacts.get(i);         boolean b = userstringlastname.matches(c.getlastname());         if (b == true) {             system.out.println(c.tostring());         }     } } 

something like

userstringlastname.tolowercase().contains(c.getlastname().tolowercase()); 

should work


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -