相关疑难解决方法(0)

转换为已实现的类

所以,我正在使用Java,尝试将一个类型转换java.sql.ResultSet为我自己的类MyResultSet

这是代码:MyResultSet.java

public class MyResultSet implements java.sql.ResultSet{
     //There are a bunch of Implemented Methods here. None of them have any custom code, They are all unchanged. Just didn't want to put huge code in here.
}
Run Code Online (Sandbox Code Playgroud)

我试图用它来代码的代码

ResultSet r = getResultSet();
return (MyResultSet)r;
Run Code Online (Sandbox Code Playgroud)

每当我运行它,我得到一个"ClassCastException".

有人可以向我解释如何投射到已实施的类吗?

java class classcastexception

1
推荐指数
1
解决办法
1105
查看次数

标签 统计

class ×1

classcastexception ×1

java ×1