import java.util.*;
public class PhoneDirec{
private int MAX=10;
private String [] validNames={"Gary","Sam","John","Jude","Alyssa","Matt","Eric","Susie","Alics","Sara"};
PhoneDirec(){
//allocate memory to names
validNames=new String[MAX];
}// accept 10 names
//I suppose to enter 10 names
public void accept(){
Scanner console = new Scanner(System.in);
for(int n = 0;n< names.length;n++)
names[n] = console.nextLine();
}
/*I also to suppose to search a names and if
names I search is valid it should display the names
*/
public void search(){
String strNames;
String namesEntered;
boolean validNames=false;
System.out.println("Enter names");
namesEntered=console.nextLine(strNames);//this part have an error
for(int x=0;x<validNames.length;++x)
{
if(namesEntered == validNames)//this part have an error
{
validNames=true;
}
}
if(validNames)
{
System.out.println("The names entered"+namesEntered);
}
else
{
System.out.println("The names you entered is invalid");
public void display search(){
/* i dont know what to do next
can someone help to this part*/
}
}
can some one help me this i I well really be happy if someone can help me this i was really stuck in here