从另一个子文件夹JAVA导入自定义类

时间:2016-11-09 03:49:37

标签: java class import

我在以下目录中有一个类:

  

examples.AgentDerivation;

另一个

  

examples.AgentClient;

问题是,第一个需要第二个,但我得到了#34;符号错误"当我尝试编译时。

有没有办法进行导入?我想做一些像import ../AgentClient;但我找不到合适的语法。

请帮忙!

1 个答案:

答案 0 :(得分:0)

从包#! /usr/bin/gnuplot # plot data in vectorfields to same directory factor=0.05 set term png # Xmin, Xmax, Ymin, && Ymax are passed as command line args set xrange [Xmin:Xmax] set yrange [Ymin:Ymax] do for [i=1:numImages] { # Control output formatting (surely there's a shortcut for this?) if (i < 10) { set output "vectors/plot00".i.".png" } else { # no else-if syntax (that I can find)? if (i < 100) { set output "vectors/plot0".i.".png" } else { set output "vectors/plot".i.".png" } } } ,您可以something.b

导入something.a班级

检查此示例:

配置:

PackageConfig

RandomA:

import container.random.A.*;

RandomB:

package container.random.A;

public class RandomA
{
    private int randomAID;

    public RandomA()
    {

    }

    /**
     * @return the randomAID
     */
    public int getRandomAID ( )
    {
        return randomAID;
    }

    /**
     * @param randomAID the randomAID to set
     */
    public void setRandomAID ( int randomAID )
    {
        this.randomAID = randomAID;
    }




}

测试:

package container.random.B;

import container.random.A.*;

public class RandomB
{
    private int RandomBID;
    private RandomA myForeignRandom;

    public RandomB(RandomA myForeignRandom)
    {
        this.setMyForeignRandom ( myForeignRandom );
    }

    /**
     * @return the randomBID
     */
    public int getRandomBID ( )
    {
        return RandomBID;
    }

    /**
     * @param randomBID the randomBID to set
     */
    public void setRandomBID ( int randomBID )
    {
        RandomBID = randomBID;
    }

    /**
     * @return the myForeignRandom
     */
    public RandomA getMyForeignRandom ( )
    {
        return myForeignRandom;
    }

    /**
     * @param myForeignRandom the myForeignRandom to set
     */
    public void setMyForeignRandom ( RandomA myForeignRandom )
    {
        this.myForeignRandom = myForeignRandom;
    }

}

输出:

  

1

     

2

输出是B中A类的ID。