首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java引用不正确

Java引用不正确
EN

Stack Overflow用户
提问于 2013-11-27 02:39:44
回答 1查看 100关注 0票数 1

我使用的是OWL-S (源代码和javadoc在这里:http://on.cs.unibas.ch/owls-api/apidocs/ )

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

代码语言:javascript
复制
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
    }
   }

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

代码语言:javascript
复制
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
    }
}

为什么?

EN

回答 1

Stack Overflow用户

发布于 2013-11-27 02:57:45

在method_A()和method_B()中执行“factory = SWRLFactory.createFactory(ont);”行存在差异。您确定在method_A()和method_B()调用之间没有修改“factory”对象吗?'x‘和'variable’对'factory‘有依赖吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20225269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档