correct cast not allowed
I think the spec allows this scenario underneath as unchecked cast, however javac does not allow it.
Can someone confirm this?
Coconha
publicclass TestCasting<Sextends Comparable><S>>{
public TestCasting(){
S a = (S)(Integer)3;// this should not fail
}
}
[590 byte] By [
coconhaa] at [2007-10-1 13:48:37]

TestCasting<S
'>' is omitted, supposed to be so?
What's 'S'?
I don't think you cast figure into Integer, it ain't an Object
Here's solution, should work
public class TestCasting {
public TestCasting() {
Integer i = new Integer(3); // that's the way to init an Integer
S a = (S)i; // not sure 'bout this one, what's S?!
}
}
yahooa at 2007-7-10 16:58:17 >

Hi,
There is no '>' omited and I am not looking for an alternative solution to the problem. I am sorry for not clarifying the problem correctly, but all I am saying is that according to the Java Specification (if I understood it right) this cast should be allowed with an 'unchecked cast' warning (there is a Bug in javac).
Can someone also confirm this?
Coconha