I am asking user candidate info then i am calling 'addcandidate' method and i am trying to hold candidate info in array list.By the way if user want to add new candidate i am getting again their info and want to add my arraylist.But its holding only last candidate info
my addcandidate method code like this
static void addcandidate(String name,String surname,String adress,String talent){
List<List<Object>>listoflist=new ArrayList<>();
List<Object>candidatelist=new ArrayList<Object>();
candidatelist.add(name);
candidatelist.add(surname);
candidatelist.add(adress);
candidatelist.add(talent);
listoflist.add(candidatelist);
System.out.println(listoflist);
}
and also mycode that to ask candidate info like that
while (true){
Scanner oku=new Scanner(System.in);
System.out.println("what kind of process do you want ? 1-Add Candidate 2-Add Employee " +
"3- add employee from candidate 4-search candidate for talent 5-print wiew");
int processtype=oku.nextInt();
if (processtype==1){
System.out.println("please enter candidate name");
String cname=oku.next();
System.out.println("please enter candidate sname");
String csname=oku.next();
System.out.println("please enter candidate adress");
String cadress=oku.next();
System.out.println("please enter candidate talent");
String ctalent=oku.next();
Candidate.addcandidate(cname,csname,cadress,ctalent);
System.out.println("do you want to continue");
String answer=oku.next();
if (answer=="n"){
break;
}
}
}
my output expectation is like this [[tom,jhn,usa,it],[peter,parker,england,language]]