[英]How to instantiate a class
I have a problem in my application , I can't instantiate a class 我的应用程序有问题,我无法实例化一个类
this is my java.lang.ClassCastException
这是我的
java.lang.ClassCastException
eclipse.emf.editeurgraphique.risque.features.StartEventFeature$CreateStartEventFeature cannot be cast to org.eclipse.graphiti.features.ICreateFeature
at eclipse.emf.editeurgraphique.risque.features.StartEventFeature.getCreateFeature(StartEventFeature.java:43)
And this is my method : 这是我的方法:
public ICreateFeature getCreateFeature(IFeatureProvider fp) {
return (ICreateFeature) new CreateStartEventFeature(fp);
}
my Interface : 我的界面:
public interface ICreateFeature extends ICreate, IFeature {
}
and my class 还有我的课
public CreateStartEventFeature(IFeatureProvider fp) {
super(fp, "Start Event", "Indicates the start of a process or choreography");
}
Your CreateStartEventFeature does not extend any class defined by you, so by calling super constructor 您的CreateStartEventFeature不会扩展您定义的任何类,因此通过调用超级构造函数
super(fp, "Start Event", "Indicates the start of a process or choreography");
you try ro run parametrized constructor from Object class. 您尝试从Object类运行参数化的构造函数。
CreateStartEventFeature needs to implement the interface: CreateStartEventFeature需要实现接口:
public class CreateStartEventFeature extends MyBaseClass implements ICreateFeature
{...}
The question is a bit confusing since it doesn't show the whole problem, but I assume CreateStartEventFeature implements ICreateFeature, so try leaving out the explicit cast: 这个问题有点令人困惑,因为它没有显示出整个问题,但是我假设CreateStartEventFeature实现了ICreateFeature,因此请尝试省略显式的强制转换:
public ICreateFeature getCreateFeature(IFeatureProvider fp) {
return new CreateStartEventFeature(fp);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.