You are viewing our Forum Archives. To view or take place in current topics click here.
(Java) Array List Help
Posted:

(Java) Array List HelpPosted:

xcbkxclutch
  • New Member
Status: Offline
Joined: Aug 08, 201211Year Member
Posts: 28
Reputation Power: 1
Status: Offline
Joined: Aug 08, 201211Year Member
Posts: 28
Reputation Power: 1
I do not understand ArrayList at all can someone help me. I am trying to make a Tile Map editor and every time you click one of the squares I want to add it to my arraylist
#2. Posted:
CodeNashor
  • New Member
Status: Offline
Joined: Oct 21, 20149Year Member
Posts: 48
Reputation Power: 1
Status: Offline
Joined: Oct 21, 20149Year Member
Posts: 48
Reputation Power: 1
ArrayList is a List, where u can store any objects.

List list = new ArrayList();

If you just want int or String in it, you have to use Generics.

List<String> list = new ArrayList<String>();

If you want to store data in it, use the add() method.

list.add("test");

An ArrayList stores objects in your save order, so list[0] is your first added data, list[1] your second, etc.

Your 'Tile Map editor':

Use buttons (squares) and each time you click on a button (square), add your data to your list.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.