> myclass cc = ...;
> ....
[quoted text clipped - 6 lines]
> cannot solve! Whereever i place the < type > thingy in the source, i
> get an error message.
List<List<List<MyClass>>> myTable =
new ArrayList<List<List<MyClass>>>();
Prefer collections to arrays of references.
You are probably better off introducing some sort of table class, rather
than working with little abstraction.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
scherer_mike@web.de - 18 Jun 2006 16:05 GMT
Thomas Hawtin schrieb:
> > myclass cc = ...;
> > ....
[quoted text clipped - 9 lines]
> List<List<List<MyClass>>> myTable =
> new ArrayList<List<List<MyClass>>>();
hi tom,
thank you very much. but it does not work this way.
in my example i would have better written
mytable = new ArrayList[N][M] for a fix N, M.
with your hint i get the compiler-message: "The type of the expression
must be an array type but it resolved to List<List<List<mmCode>>>."
but in general i agree: the data abstraction is poor. i am also a
novice in this kind of object-modelling.
thank you very much
Oliver Wong - 19 Jun 2006 22:17 GMT
> Thomas Hawtin schrieb:
>
[quoted text clipped - 22 lines]
> but in general i agree: the data abstraction is poor. i am also a
> novice in this kind of object-modelling.
Have you considered creating a new class to represent your tables?
class Table<T> {
final private FixedLengthList<FixedLengthList<T>> data;
final private int width, height;
public Table(int width, int height) {
this.data = new FixedLengthList<List<T>>(width);
this.width = width;
this.height = height;
}
public T get(int x, int y) {
this.data.get(x).get(y);
}
/*put more code here*/
}
class FixedLengthList<T> extends AbstractList<T> {
private final int length;
public FixedLengthList(int length) {
this.length = length;
}
/*put more code here*/
}
- Oliver