arraylist

Hi- I am using the ArrayList in my program. I declare it once in the main and have 3 other methods that are called when needed. One method prompts the user for a name and adds it to the arraylist. The second method prompts for another name and adds it as well, depending upon if the user said yes or no. The final method will print the contents of the arraylist(all the names and number of entries in the arraylist). I know that I need to pass variable names to each of the methods. The first metod will get the name of the arraylist. The second method I currently don't have anything being passed to it. The final method receives the name of the first entry. See the code below. import java.util.ArrayList;

First of all, it will help a lot if you use UBB CODE tags when you post your code here. They will preserve the formatting in your code so that we can read it more easily.

With that said, I tried to compile your code, but I don't have the GameHelper class. Even if I ignore those errors, there are a few other errors that stop your code from even compiling, so I'm surprised that you can run it. The first error (other than ones involving the GameHelper class) is

This is in the method declared as

Your comment says that you are trying to add the name to an ArrayList, but myname is a String (not an ArrayList). If I understand what you are doing, the parameter should be an ArrayList instead of a String so that you can add the name to the ArrayList.

Hopefully this will help with your problems. If not, please post your modified code. (Be sure to use CODE tags.) I will be glad to help you further from there.

Do you mean to pass the parameter 'ArrayList' as in the following: private String getname(ArrayList), or would I pass the name of the arraylist:ArrayList<String> myname = new ArrayList<String>( ); namely, myname? Also, in terms of the UBB code guidelines, can I just click on the CODE button below and insert appropriate lines of code in between the tags and all is well?