我有两个班级:
public abstract class Entry {
private static String LIST_QUERY = "SELECT * FROM \"%s\"";
.
.
.
protected static <T extends Entity> List<T> all(Class<T> cls) {
/*Here I want to load whole database. For each row create own object. For example Article(class is below)*/
}
}
class Article extends Entry {
.
.
.
public static List<Article> all() throws SQLException {
return Entry.all(Article.class);
}
}
问题是Entry.all()方法内部如何创建Article对象或从Entry继承的任何对象? 我的变种是错误的:
cls<T> instance_of_entity = new cls<T>();//wrong
cls instance_of_entity = new cls();//wrong