由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Help! ClassCastException
相关主题
get full class nameAsk a simple question about throw exception, bow bow bow
我想把一个Arraylist转成String[]Help Cookie getMaxAge() always return -1
java这个是什么逻辑?这个是JSP的什么技术
ERROR!java.io.RandomAccessFile.readInt新手问问这个错在哪儿?
question about Exeption求救。java的格式化输出
[合集] How to get all classes under a package?An experiment with JVM Garbage Collection Schemes
如何造Array of Generic TypeStack Frame of your JVM implementation
Where I can find comparison of JVMsThe shape of JVM stack frame
相关话题的讨论汇总
话题: getclass话题: getname话题: vector话题: when
进入Java版参与讨论
1 (共1页)
z****g
发帖数: 2497
1
I got a very weird exception
code:
...
//isotopes is a Vector
cdk.Isotope iso = (cdk.Isotope)isotopes.elementAt(0);
....
when it runs this line, it throws a ClassCastException
But when I printout isotopes.elementAt(0).getClass().getName()
it print out "cdk.Isotope".
Can't figure out why.
Please help!
xt
发帖数: 17532
2
This is very strange. You must have sth else wrong.
xt
发帖数: 17532
3

It can't be, otherwise JVM will throw LinkageError
t***t
发帖数: 6066
4
recomiple everything?

【在 z****g 的大作中提到】
: I got a very weird exception
: code:
: ...
: //isotopes is a Vector
: cdk.Isotope iso = (cdk.Isotope)isotopes.elementAt(0);
: ....
: when it runs this line, it throws a ClassCastException
: But when I printout isotopes.elementAt(0).getClass().getName()
: it print out "cdk.Isotope".
: Can't figure out why.

z****g
发帖数: 2497
5
It is a fresh compile. Really don't get it.
Anyway, I will try it.

【在 t***t 的大作中提到】
: recomiple everything?
1 (共1页)
进入Java版参与讨论
相关主题
The shape of JVM stack framequestion about Exeption
Top Ten Errors Java Programmers Make(10)[合集] How to get all classes under a package?
Is this a Bug or not?如何造Array of Generic Type
Answer to "Is this a Bug or not? "Where I can find comparison of JVMs
get full class nameAsk a simple question about throw exception, bow bow bow
我想把一个Arraylist转成String[]Help Cookie getMaxAge() always return -1
java这个是什么逻辑?这个是JSP的什么技术
ERROR!java.io.RandomAccessFile.readInt新手问问这个错在哪儿?
相关话题的讨论汇总
话题: getclass话题: getname话题: vector话题: when