Small question about arrays

T

thedownfallen

Hi. Just a small problem. I would like to create a array of objects,
wtih each object's constructor having two parameters. How do I do
this?

Thanks

reply to (e-mail address removed)
 
P

Philipp Leitner

Well, just like you would create any new object:

MyObject[] array = new MyObject[size];
for(int i=0; i<array.length; i++) {
array = <CONSTRUCT OBJECT>
}

/philipp
 
T

Thomas Weidenfeller

Hi. Just a small problem. I would like to create a array of objects,
wtih each object's constructor having two parameters. How do I do
this?

class Bla {
public Bla(int a, int b) { ... }
}

Bla data[] = {
new Bla(1, 2),
new Bla(3, 9),
new Bla(99, 12)
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top