For instance, I have a custom class called Boxcar, used like this:
public Boxcar(String c, int u, boolean r)
In another class, I initialize an ArrayList of Boxcars called train like this:
private ArrayList<Boxcar> train = new ArrayList<Boxcar>();
The problem I have is, I need to change String c to something else for every Boxcar in train. I imagine I need a for each loop so what I have now is:
public void setCargo(String replace)
{
for(Boxcar b: train)
{
b = new Boxcar(replace);
}
}
Which of course doesn't compile as it needs values for int u and boolean r. How can I access String c? Sorry for the noobish programming and I hope I was specific enough.