Anyone know the best way to create multiple objects of the same class with different data and names using a loop in Java?
Here is psuedocode for what I mean
Code:for(x = 1; Line > x; x++) { host host + x = new host(somarray[x]); ... }
[quote author=Ashcrow link=board=9;threadid=7723;start=0#msg70526 date=1063417661]
Anyone know the best way to create multiple objects of the same class with different data and names using a loop in Java?
Here is psuedocode for what I mean
[/quote]Code:for(x = 1; Line > x; x++) { host host + x = new host(somarray[x]); ... }
i think you could do it if you use an array rather than just host + x, like:
host host[x] = new host(somarray[x]);
because in most languages you can't declare variable names from variables (and when you can it can get screwy).
Bookmarks