T
Taria
Hello all,
I've tried many different ways to assign a value to the position of my
choice in a data structure, ArrayList and would appreciate any hints
how to do this. My program as follows (short version):
import java.util.*;
public class MyProg1 {
public static void main(String[] args) {
ArrayList data = new ArrayList();
ArrayList [] table = new ArrayList[5];
data.add(1);
data.add(3);
data.add(4);
for ( int i = 0; i < 3; i++ ){
//table.add(data.get(i)); //these are 3 different
failed ways that I've tried
//table=data.get(i);
//table(i)=data.get(i);
table[0] = data;
}
}
Essentially, I want to assign the first value of data to the first
element of table, the second value of data to table(2,0), and 3rd
element to table(3,0). The statement table[0] = data puts the whole
arrayList data to table(0) which is not what I want. How do you
reference the elements of table? I thought I understood the
referening until now. :x
Any help is appreciated.
-t
I've tried many different ways to assign a value to the position of my
choice in a data structure, ArrayList and would appreciate any hints
how to do this. My program as follows (short version):
import java.util.*;
public class MyProg1 {
public static void main(String[] args) {
ArrayList data = new ArrayList();
ArrayList [] table = new ArrayList[5];
data.add(1);
data.add(3);
data.add(4);
for ( int i = 0; i < 3; i++ ){
//table.add(data.get(i)); //these are 3 different
failed ways that I've tried
//table=data.get(i);
//table(i)=data.get(i);
table[0] = data;
}
}
Essentially, I want to assign the first value of data to the first
element of table, the second value of data to table(2,0), and 3rd
element to table(3,0). The statement table[0] = data puts the whole
arrayList data to table(0) which is not what I want. How do you
reference the elements of table? I thought I understood the
referening until now. :x
Any help is appreciated.
-t