Write a program FriendsArray
that initializes an Array
capable of holding 1000 String
values. Then write a loop that uses a Scanner
to have the user enter a series of friends' names (using in.nextLine()
), storing the friends' names in the Array as it goes. A blank entry ""
is the sentinel value that ends the input. After that, the entire list of friends is displayed.
Because the number of friends entered will be less than the size of the Array, a variable size
will be necessary to keep track of the size of the array. This variable is also used to store each new value at the correct location in the array.
Sample output:
Enter a friend's name [blank line to finish]: Dana
Enter a friend's name [blank line to finish]: Gary
Enter a friend's name [blank line to finish]: Ruthie
Enter a friend's name [blank line to finish]: Aaron
Enter a friend's name [blank line to finish]:
Here are your friends:
Dana
Gary
Ruthie
Aaron