I'm translating a Java program into X10 and have run into a couple problems that I was wondering if anyone could help me translate.
Here's one Java segment that I'm trying to translate:
ArrayList<Posting>[] list = new ArrayList[this.V];
for (int k=0; k<this.V; ++k) {
list[k] = new ArrayList<Posting>();
}
And here's what I've done in X10:
var list:ArrayList[Posting]=new ArrayList[Posting](this.V);
for (var k:int=0; k<this.V; ++k) {
list(k)=new ArrayList[Posting]();
}
The line that's generating a mess of error statements is this:
list(k)=new ArrayList[Posting]();
Any suggestions and maybe an explanation on what I'm doing wrong?
Here is code that should work for you:
And you can also do
i.e. use a single statement to create an initialized array.