有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

在java中,字段和类之间的关系是什么?

请参考此API。链接是:

http://download.carrot2.org/stable/javadoc/org/carrot2/text/preprocessing/pipeline/CompletePreprocessingPipeline.html

Class CompletePreprocessingPipeline

Field Summary
 DocumentAssigner   documentAssigner
          Document assigner used by the algorithm, contains bindable attributes.

然后我找到了一些这样使用completePreprocessingPipeline的例子

completePreprocessingPipeline().documentAssigner()exactPhraseAssignment(true)

我不理解“completePreprocessingPipeline”和“documentAssigner”在“字段与类”方面的关系


共 (4) 个答案

  1. # 1 楼答案

    你的例子一定来自其他语言。可能是一种可以在JVM上运行或查看Java库的脚本语言

    在java中可能是正确的:

    CompletePreprocessingPipeline completePreprocessingPipeline = new CompletePreprocessingPipeline();
    completePreprocessingPipeline.documentAssigner.exactPhraseAssignment = true;
    

    你实例化一个类,然后得到一个对象。然后,如果字段修饰符允许,您可以引用对象中的字段(例如,如果它是public

  2. # 2 楼答案

    字段是类的成员变量。这个领域的类型可能确实是另一个类别

    在本例中,他们的方法似乎是一个“getter method”.documentAssigner(),它返回documentAssigner字段,该字段的类型为DocumentAssigner

  3. # 3 楼答案

    I do not understand the relationship between "completePreprocessingPipeline" and "documentAssigner" in terms of "field vs.class".

    那是因为你的问题毫无意义。completePreprocessingPipeline()和documentAssigner()都是方法代码中根本没有字段。广告中缺少一个“.”

  4. # 4 楼答案

    类包含字段。该类的所有实例都有这些字段

    http://download.oracle.com/javase/tutorial/java/javaOO/classes.html

    在第一个例子中,自行车类有三个字段:cadence、dear和speed

    这是标准的Java代码结构,没有什么特别之处。我建议你学习一些Java,Javadocs可能会更有意义