R
rwfields
Hello,
Here is the code:
import java.util.Stack;
public class Clone implements Cloneable {
Stack<Object> stack = new Stack<Object>();
public Clone() {
}
public Object clone() throws CloneNotSupportedException {
Clone rv = (Clone) super.clone();
rv.stack = (Stack<Object>) stack.clone();
return rv;
}
public static void main (String[] args) throws
CloneNotSupportedException {
System.out.println("hello world!");
Clone a = new Clone();
Clone b = (Clone) a.clone();
}
}
It seems like the explicit cast should prevent the warning, but it does
not. Without the explicit cast, the code generates a compile error. I
can live with warnings, but it sure seems like what I am trying to do
is valid. Did the language designers (1.5) miss this on accident, or
is there something simple that I am missing? Does anybody have any
thoughts?
Thanks,
Randall
Here is the code:
import java.util.Stack;
public class Clone implements Cloneable {
Stack<Object> stack = new Stack<Object>();
public Clone() {
}
public Object clone() throws CloneNotSupportedException {
Clone rv = (Clone) super.clone();
rv.stack = (Stack<Object>) stack.clone();
return rv;
}
public static void main (String[] args) throws
CloneNotSupportedException {
System.out.println("hello world!");
Clone a = new Clone();
Clone b = (Clone) a.clone();
}
}
It seems like the explicit cast should prevent the warning, but it does
not. Without the explicit cast, the code generates a compile error. I
can live with warnings, but it sure seems like what I am trying to do
is valid. Did the language designers (1.5) miss this on accident, or
is there something simple that I am missing? Does anybody have any
thoughts?
Thanks,
Randall