[英]Exception in thread “main”
Im getting Exception in thread "main" java.lang.Error: Unresolved compilation. 我在线程“主” java.lang.Error中获取异常:无法解析的编译。
What am I doing wrong? 我究竟做错了什么?
public class idsbasedagent{
JDCaptor captor ;
public idsbasedagent(){
captor=new JDCaptor();
}
public static void main(String[] args){
System.out.println("؟ھت¼×¥°ü");
idsbasedagent agent=new idsbasedagent();
agent.capturesFromDevice();
}
}
Exception in thread "main": 线程“主”中的异常:
java.lang.Error: Unresolved compilation problem:
java.lang.Error:未解决的编译问题:
The method
capturesFromDevice()
is undefined for the typeidsbasedagent
atidsbasedagent.main(idsbasedagent.java:11)
该方法
capturesFromDevice()
是未定义的类型idsbasedagent
在idsbasedagent.main(idsbasedagent.java:11)
The main method is calling method "capturesFromDevice" on the "agent" object of type "idsbasedagent". 主要方法是在“ idsbasedagent”类型的“ agent”对象上调用方法“ capturesFromDevice”。 However , your class "idsbasedagent" doesn't have the method "capturesFromDevice()" defined in it.
但是,您的类“ idsbasedagent”中没有定义方法“ capturesFromDevice()”。 So you need to define that method for eg:
因此,您需要为以下方法定义该方法:
public class idsbasedagent{
JDCaptor captor ;
public idsbasedagent(){
//...
}
public void captureFromDevice() {
//implementation
}
}
Or it could be that "captureFromDevice" is a method of JDCaptor class. 也可能是“ captureFromDevice”是JDCaptor类的方法。 In which case, you would need to call that method on the the agent's "captor" member variable like so:
在这种情况下,您需要在代理的“ captor”成员变量上调用该方法,如下所示:
agent.captor.captureFromDevice()
Sidenote: With regards to class names, the java coding convention dictates that class/interfaces should be capitalised. 旁注:关于类名,Java编码约定规定应使用大写的类/接口。 Have a look at this: http://www.oracle.com/technetwork/java/codeconventions-135099.html
看看这个: http : //www.oracle.com/technetwork/java/codeconventions-135099.html
The rest of the convention topics can be found here: http://www.oracle.com/technetwork/java/codeconvtoc-136057.html 其他约定主题可以在这里找到: http : //www.oracle.com/technetwork/java/codeconvtoc-136057.html
Hope that helps. 希望能有所帮助。
The Class idsbasedagent
is expected to have a method 'capturesFromDevice' if you want its instances to be able to call it. 如果您希望类实例的实例能够调用它,则
idsbasedagent
类应具有方法“ capturesFromDevice”。
You cannot call a method which has not been defined. 您不能调用尚未定义的方法。
public class idsbasedagent{
JDCaptor captor ;
public idsbasedagent(){
captor=new JDCaptor();
}
public void capturesFromDevice(){
//Method action here
}
public static void main(String[] args){
System.out.println("؟ھت¼×¥°ü");
idsbasedagent agent=new idsbasedagent();
agent.capturesFromDevice();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.