この質問をするのはばかげていると思いますが、実際には問題がわかりません。それをコンパイルすると ClassCastException が発生しました
これがスーパークラス
package elements;
import persistence.postgres.DataSource;
import persistence.postgres.IdBroker;
import persistence.postgres.PersistenceException;
import util.Util;
public class Hotspot {
private double lat;
private double lng;
private long id;
private String username;
private String time_stamp;
private String point_of_interest;
private String comment;
public Hotspot(double lat, double lng, String username, String comment, String p_o_i) {
this.lat = lat;
this.lng = lng;
this.username = username;
try {
this.id = IdBroker.getId(new DataSource().getConnection());
} catch (PersistenceException e) {
e.printStackTrace();
}
time_stamp = Util.timeStamp();
this.comment = comment;
this.point_of_interest = p_o_i;
}
public Hotspot(double lat, double lng, String username, long id, String time_stamp) {
this.lat = lat;
this.lng = lng;
this.username = username;
this.id = id;
this.time_stamp = time_stamp;
}
//Getter Setter for all variable and HashCode/Equals
}
そして、これはサブコールです
package persistence.postgres;
import elements.Details;
import elements.Hotspot;
public class HotspotProxy extends Hotspot {
private HotSpotDAOpostgres hsd;
private Details details;
//insert
public HotspotProxy(double lat, double lng, String username, String comment, String poi) {
super(lat, lng, username, comment, poi);
this.hsd = new HotSpotDAOpostgres();
}
//Retrieve
public HotspotProxy(double lat, double lng, String username, long id, String time_stamp) {
super(lat, lng, username, id, time_stamp);
this.hsd = new HotSpotDAOpostgres();
}
public String getPointOfInterest() {
redifined method
}
public String getComment() {
//redifined method
}
}
そして、これは私にエラーを与えます
Hotspot h = new Hotspot(31.124, 43.123, "name", "comment", "point of interest");
HotspotProxy hp = (HotspotProxy)h;
どこで失敗しているか教えてください。提案をありがとう