java - String search with "startsWith()" -
i've been working on email directory program past couple of day , in 1 of methods i'm trying make search function searches email based off character inputs of user. i'm trying make method loops , user types in email 1 character @ time until 1 email in array constructed method. heres code: private void searchcontact() { string[] newrecords=new string[emailrecords.size()]; //temp array searching arraylist<string> searchrecords=new arraylist<string>(); //to passed insertion sort newrecords=emailrecords.toarray(newrecords); for(string records: newrecords) { scanner search=new scanner(system.in); //setup user input string letter; string searchval; system.out.println("please enter first letter of email you're trying find."); letter=search.nextline(); if (searchrecords.size()!=1) { (int i=0; i<newrec