Ok i need some help with a little syntax problem. I have a class and i want it to put it into an arraylist, and populate the arraylist using a for loop.
Here is an example of what i want:
public class w{
int x;
int y;
}
Arraylist m = new Arraylist();
for(int i=0; i<n;i++)
{
m[i].add(w.x);
m[i].add(w.y);
}
Yes the code isn’t functioning its just an example of what i want it to do. I don’t know the syntax and I want an arraylist with classes that can be retrieved by giving the i and get the both variables only by that ‘i’;
Any help will be apreciated. Thank you very much for your time, sorry for the lousy description but i can’t be more specific.
It’s not clear what you’re trying to accomplish, but perhaps this will be enough of a guide as to how to use
ArrayListproperly. I changed your class name fromwtoWto match the usual Java coding conventions.