gpt4 book ai didi

Java 引用不正确

转载 作者:太空宇宙 更新时间:2023-11-04 15:22:55 25 4
gpt4 key购买 nike

我正在使用 OWL-S API(此处的源代码和 javadoc: http://on.cs.unibas.ch/owls-api/apidocs/ )

如果我这样做,我会得到正确的结果:

public class Example {
private static ISWRLFactory factory; //is a interface
private string url = "http://...";
private Service aService;
private OWLOntology ont;

void method_A(){
URI aURI = URI.create(url);
OWLKnowledgeBase aKB = OWLFactory.createKB();
aService = aKB.readService(aURI);
ont = aKB.createOntology(aURI);
ont.createService(aService.getURI());

}

void method_B(){
factory = SWRLFactory.createFactory(ont);
Atom builtAtom = factory.createNotEqual(x, variab); //x and variab are two variable
}
}

但是如果我这样做,我不会得到正确的结果:

public class Example {
private static ISWRLFactory factory; //is a interface
private string url = "http://...";
private Service aService;
private OWLOntology ont;


void method_A(){
URI aURI = URI.create(url);
OWLKnowledgeBase aKB = OWLFactory.createKB();
aService = aKB.readService(aURI);
ont = aKB.createOntology(aURI);
ont.createService(aService.getURI());
factory = SWRLFactory.createFactory(ont);
}

void method_B(){
Atom builtAtom = factory.createNotEqual(x, variab); //x and variab are two variable
}
}

为什么?

最佳答案

执行“factory = SWRLFactory.createFactory(ont);”时存在差异method_A() 和 method_B() 中的行。您确定“工厂”对象在 method_A() 和 method_B() 调用之间没有被修改吗? “x”和“变量”对“工厂”有一定的依赖性吗?

关于Java 引用不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20225269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com