I have a list of names from a text file: MARY, PATRICIA, LINDA, BARBARA, ELIZABETH, JENNIFER, MARIA that I put into a String Array. I want to be able to search the array, but I am having problems. I'd like to have it sorted using a quicksort algorithm, and to search using the Binary search, but I'm trying to get something simple to work. If I searched "MARY" the result would be "MARY is not it"
public class NameSearch {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
FileReader woMen = new FileReader("names.txt");
String[] womenArray;
womenArray = new String[64];
BufferedReader reader = new BufferedReader(woMen);
String line = null;
for (int j=0;j<womenArray.length;j++)
{
womenArray[j] = reader.readLine();
}
reader.close();
int x = 0, y =0;
System.out.println("Name?");
Scanner keyboard = new Scanner(System.in);
String input = keyboard.nextLine();
for(int i=0;i<womenArray.length;i++) {
if (input == womenArray[i]) {
System.out.println("Found! "+input);
}
System.out.println(womenArray[i]+" is not it");
}
}
}