import java.util.*;
public class EmployeeNames{
private String EmpYee [];
private int count;
int x;
public EmployeeNames(int size){
String EmpYee []=new String [size];
count=0;
}
public EmployeeNames(){
this(10);
}
public boolean isFull(){
return count= EmpYee.length;
}
public boolean isEmpty(){
return count=0;
}
public void add(int x){
if(! isFull())
EmpYee[count++]=x;
else
System.out.println("\n Sorry! Elements of Array is full:");
}
public int search(int x){
boolean flag=false;
for(int i=0;i<this.count;i++)
if(names.equals(EmpYee[i])){
namesWasFound=true;
x=i;
}
}
if(flag=false)
x=-1;
return x;
}
}
public void display(){
for(int i=0;i<EmpYee.length;i++)
System.out.println(EmpYee[i]+ "");
}
public static void main(String [] args)}{
int choice;
String names;
String num2;
EmployeeNames e= new EmployeeNames();
Scanner s= new Scanner (System.in);
System.out.print("Welcome");
do
{
System.out.println("\n[1]ADD NAMES\n[2] SEARCH NAMES\N[3]DISPLAY NAMES\n[4]EXIT");
System.out.println(" Enter Choice");
choice=s.next();
switch(choice)
{
case 1: System.out.println("\n Enter Names");
num2=s.next();
e.add(num2);
break;
case 2: if(!(e.isEmpty())){
System.out.println("\nEnter names to search");
names=s.next();
System.out.println(names+"is in position"+m.search(num2));
}
else
System.out.println("\n There no names to search:\n Add names first:");
break;
case 3: System.out.println("\n Names Entered are:");
e.display();
// System.out.println();
case 4: System.out.println("\nThank You!!:");
break;
default: System.out.println("\n Please enter choices given in menu:");
break;
}while(!(choice==4));
}
}
Can someone here teach how to get the position of the array...