Note that there are some explanatory texts on larger screens.

plurals
  1. POi need to create a ArrayList for my class project
    text
    copied!<p>I have written what I can and have come to a point where I cant figure out why it is not saving the data. Below is the File Test, then the File, and the Array file I have made. please some help...</p> <p>$</p> <pre><code>import java.util.Scanner; public class FriendsListTest { public static void main( String[] args) { FriendsList friendsList = new FriendsList(); char selection; Scanner input = new Scanner( System.in ); do { //display menu System.out.println("\n--------------"); System.out.println("Main Menu\n"); System.out.println("1. Add a friend "); System.out.println("2. Delete a friend "); System.out.println("3. Show List "); System.out.println("4. Exit"); //selection results selection = input.next().charAt(0); switch(selection){ case '1': FriendsList.AddFriends(); break; case '2': FriendsList.RemoveFriend(); break; case '3': FriendsList.DisplayArray(); break; case '4': break; default: System.out.println("Invalid Selection"); }//end Switch }while( selection != 4);//end do }//end main }//end FriendsListTest </code></pre> <p>$ $</p> <pre><code>import java.util.Scanner; import java.util.ArrayList; public class FriendsList { public static void AddFriends() { Scanner input = new Scanner( System.in ); ArrayList&lt;Friends&gt; friend = new ArrayList&lt;Friends&gt;(20); System.out.println("\n--------------"); System.out.println("Please enter Name"); String name = input.nextLine(); //reads name System.out.println("Please enter Age"); int Age = input.nextInt(); friend.add(new Friends( Age, name)); }//end AddFriends public static void RemoveFriend() { ArrayList&lt;Friends&gt; friend = new ArrayList&lt;Friends&gt;(20); Scanner input = new Scanner( System.in ); System.out.println("\n--------------"); System.out.println("Please enter Name of person you wish you remove"); String name = input.nextLine(); friend.remove(name); }//End RemoveFriend public static void DisplayArray() { ArrayList&lt;Friends&gt; friend = new ArrayList&lt;Friends&gt;(20); System.out.print(friend); }//end DisplayArray }//end class FriendsList </code></pre> <p>$ $</p> <pre><code> class Friends { private String nName; private int nAge; public Friends(int Age, String name) { nName = name; nAge = Age; } public String getName() { return nName; } public int getAge() { return nAge; } }//end class person </code></pre> <p>Ok after your suggestions I was able to get it to store data but now I have the problem of removing data. It doesn't throw any errors when removing data but the data remains. If I would repost the program if you with the edits that I have done.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload