Hello

Hi I have to finish a project to create a phonebook. I'm just a student and a beginner in the language of java. On my programs I can enter a contact information
search by last name and save to disk.

I got problems with save to disk (Also where should I create a file.txt ? I think I need create a file if I want to save my contact. But should I create inside eclipse or on my local machine ?)

and also I created a method compare to and I use the the method arrays sort...The reason because I used those 2 method it is that I want to give the possibility to the user to find the information based on the last name.But for what it concerns this last part I got several problems.

I will appreciate any advise how I can make my programs working. thanks

Note: The program has three classes and I'm using eclipse as compiler.

Code:
import java.util.*;
import java.io.*;
import java.util.Arrays;

public class Menu
{
   public static void main(String[] args) 
   {
      Scanner scan = new Scanner(System.in);

      AddressBook contacts = new AddressBook();
      int input = 0;
      do
      {
         //displays the options 
    
         System.out.println("1 Add contact");
         System.out.println("2 View all contacts");
         System.out.println("3 Retrive by Last Name");
         System.out.println("4 Quit");
         System.out.print("Enter a choice: ");
         input = scan.nextInt(); 
         
         if(input == 1) 
         {
            contacts.Input();
            }
         else if(input == 2)
         { 
          contacts.viewEntries();
          }
         else if(input == 3)
         {
            contacts.retriveByLastName();
            }
         else if(input == 4) 
         {
            System.exit(0);
            }
         else;
      }
      while(input==1||input==2||input==3||input==4);
   }
}



import java.util.Scanner;
import java.io.*;
import java.util.Arrays;

public class AddressBook
{  
   private int top = 0; 
   private static final int MAX = 100;
   private ContactList[] list;

   public AddressBook()
   {
      list = new ContactList[MAX]; 
   }

   public void Input()
   {
      Scanner s = new Scanner(System.in); 
      String name = "";
      String lastName = "";
      String address = "";
      String phone = "";
      String email = "";
      String notes = "";


      System.out.println("Add First Name: ");
      name = s.nextLine(); 
      System.out.println("Add Last Name: ");
      lastName = s.nextLine(); 
      System.out.println("Add Address: ");
      address = s.nextLine(); 
      System.out.println("Add E-mail: ");
      email = s.nextLine(); 
      System.out.println("Add Phone Number: ");
      phone = s.nextLine(); 
      System.out.println("Add Note(s): ");
      notes = s.nextLine();  


      ContactList entry = new ContactList(name, lastName, address, email, phone, notes);

      list[top] = entry;
      top++;
   }

   public void viewEntries()
   {
      for (int index = 0; index < top; index++)
      {
         System.out.println("CONTACT SUMMARY");
         System.out.println("");
         System.out.println((index+1) + " Name:"+
               list[index].getName());
         System.out.println("Last Name:"+
               list[index].getLastName());
         System.out.println("Address:"+
               list[index].getAddress());
         System.out.println("Phone:"+
               list[index].getPhone());
         System.out.println("E-mail:"+
               list[index].getEmail());
         System.out.println("Notes:"+
               list[index].getNotes());
         System.out.println("");
         System.out.println("************");
      }

   }

   public void Sort()
   {
      String[] lastName = {"list"};
      Arrays.sort(lastName);
   }
   public void retriveByLastName()
   {

// here i want to allow the research for the user
   }
   public void SaveToDisk()
   {
      try
      {
         FileWriter fstream = new FileWriter("list.txt");
         BufferedWriter out = new BufferedWriter(fstream);
         out.writelist(ContactList[] list);

         out.close();
      }
      catch (Exception e)
      {

         System.err.println("Error: " + e.getMessage());
      }
   }
}
import java.io.*;
import java.util.Arrays;

public class ContactList implements Comparable<ContactList>
{
   private String name;
   private String lastName;
   private String address;
   private String phone;
   private String email;
   private String notes;

   public ContactList(String name, String lastName, String address, String phone, String email, String notes)
   {
      this.name = name; 
      this.lastName = lastName; 
      this.address = address; 
      this.email = email; 
      this.phone = phone; 
      this.notes = notes; 
   }

   public String getName()
   {
      return name;
   }

   public String getLastName()
   {
      return lastName;
   }

   public String getAddress()
   {
      return address;
   }

   public String getEmail()
   {
      return email;
   }

   public String getPhone()
   {
      return phone;
   }

   public String getNotes()
   {
      return notes;
   }


   public int compareTo(ContactList o) 
   {
      /* Compares two objects. Returns -1 if the object that calls this method is less then contactB, returns 0 if the object that calls this
   method is == contactB, and returns +1 if the object that calls this method is > contactB. */

      return lastName.compareTo(o.getLastName());
   }

}