Java类型的方法未定义 [英] Method undefined for type Java

查看:448
本文介绍了Java类型的方法未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在弄清楚我在哪方面出错时遇到了真正的麻烦。使用Java中的WEKA构建系统来研究关联,并正在尝试实现Apriori算法。当前的代码是:

Having real trouble figuring out where i'm going wrong on this one. Building a system using WEKA in java to study associations and am trying to implement the Apriori algorithm. Currently this is the code:

package model;

import weka.associations.*;
import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;

public class Apriori {

public static void main(String args[]) throws Exception {
    String dataset = "/Users/andrew/workspace/Movies/src/data/tagsfinal.arff";
    DataSource dsource = new DataSource(dataset);
    Instances dapriori = dsource.getDataSet();


    Apriori apriori = new Apriori();
     apriori.buildAssociations(dapriori);

    System.out.println(apriori);
  }
}

通过查看网络上的几种实现,这似乎是一种被广泛接受的方法,但是我在 apriori.buildAssociations行上收到一条错误消息,告诉我该方法对于Apriori类型未定义。此外,我用于关联的import语句仅用作包类型,并且在尝试将其扩展为:

From looking at several implementations across the web this seems to be a widely accepted method of doing this however i receive an error on the "apriori.buildAssociations" line telling me that the method is undefined for the type Apriori. Furthermore, the import statement i use for the associations only works as the package type and when trying to extend it to :

import weka.associations.Apriori;

这会引发一条错误消息,即导入weka.associations.Apriori与在同一文件。我搜寻了StackOverflow和其他资源,并意识到那里有很多类型未定义的问题,但是还没有找到解决该问题的方法。

this throws an error message that "The import weka.associations.Apriori conflicts with a type defined in the same file". I have scoured StackOverflow alongside other resources and realize there is a lot of type undefined questions out there however have yet to find a solution to this problem. Any help/pointers would be greatly appreciated.

推荐答案

您的课程也被命名为 Apriori ,因此您遇到名称冲突。

Your class is also named Apriori, so you are experiencing a name clash.

您应将自己的类的名称更改为其他名称(例如 AprioriTest )。在不太可能的情况下,您确实需要将您的类命名为 Apriori ,那么您就必须使用全名来引用该库的实现:

You should change the name of your own class to a different name (e.g. AprioriTest). In the unprobable case where you would really need your class to be named Apriori, then you would have to refer to the library's implementation by it's full name:

weka.associations.Apriori apriori = new weka.associations.Apriori();
apriori.buildAssociations(dapriori);

这篇关于Java类型的方法未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆