about ClassCastException

i have this code

Test1.java

public class Test1 {

/** Creates a new instance of Test1 */

public Test1() {

}

}

Test2.java

public Test2() {

}

public static void main(String[] args) {

Test1 t1 = new Test1();

Test2 t2 = (Test2) t1;

}

}

two files compile fine, when i run it, i got a ClassCastException?

[401 byte] By [windyboycn] at [2007-9-27 14:46:16]
# 1
"To cast is an explicit conversion from one data type to another" but must to have a relationship between them, a common "nature", so it would be possible if both Test1 and Test2 extend the same class or are implementation of same interface.
dekassegui at 2007-7-5 22:46:15 > top of Java-index,Archived Forums,Java Programming...