I tried to place the 2nd if statement inside the loop statement and in the first if statement, and it keeps on saying "exists" cannot be a resolved to a variable. :(
import java.util.*;
public class MT_Assign2_Phonebook_LinkedList {
public static void main(String[] args) {
LinkedList <String> AddEntry_list = new LinkedList <String> (); //FirstName & Last Name
LinkedList <String> Number_list = new LinkedList <String> (); //Telephone Number
String firstname, lastname;
String phonenum;
Scanner input = new Scanner (System.in);
System.out.println ("MAIN MENU");
System.out.println ("1 = ADD Phonebook Entry");
System.out.println ("2 = DELETE Phonebook Entry");
System.out.println ("3 = VIEW All Entries ");
System.out.println ("4 = SEARCH Entries ");
System.out.println ("5 = Quit ");
//ENTER USER'S CHOICE
System.out.print ("\nPlease Select your choice: ");
int choice = input.nextInt();
if (choice == 1) {
System.out.println ();
System.out.println ("You chose to ADD PHONEBOOK ENTRY");
//.get (record the input data ni user) with VALIDATION
for (int database_pb = 0; database_pb <AddEntry_list.size (); database_pb++) {
if (AddEntry_list.get(database_pb).contains(firstname) && AddEntry_list.get(database_pb).contains(lastname))
{
System.out.println ("\n ERROR OCCURED: PHONEBOOK ENTRY ALREADY EXIST!\n END OF PROGRAM");
System.exit(0);
boolean exists = true; //validate
}//END IF
if (exists == false) {
System.out.print ("First Name: ");
System.out.print ("Last Name: ");
System.out.print ("Number (+63): ");
AddEntry_list.add (firstname + " " + lastname + " " + phonenum + " ");
Number_list.add (phonenum + " " + firstname + " " + lastname + " " );
System.out.println ("Successfully Added Entry! ");
} boolean exists = false;
}//END OF FOR LOOP
}//CHOICE 1
else
System.out.println ("Invalid Input!");
} //public static
}//public class end