所以,我正在使用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".
有人可以向我解释如何投射到已实施的类吗?