猿问

错误:找不到符号,声明了对象,但看不到公共变量

我正在


systemB\Plumber.java:44: error: cannot find symbol

            FilterOut.Connect(FilterWildPoints.pipe1);

                                              ^

symbol:   variable pipe1

location: variable FilterWildPoints of type MiddleFilter

systemB\Plumber.java:56: error: cannot find symbol

            FilterWildPoints.pipe1.start();

                            ^

symbol:   variable pipe1

location: variable FilterWildPoints of type MiddleFilter

2 errors

即使您,FilterWildPoints也具有公共成员变量pipe1。


一个好主意是让“狂野点过滤器”将流分成另外两个管道,并将其中一个管道连接到输出。


Plumber.java:


package systemB;

public class Plumber

{

   public static void main( String argv[])

   {

        SourceFilter FilterIn = new SourceFilter("./datasets/FlightData.dat");

        MiddleFilter FilterTemperature = new MiddleFilterTemperature();

        MiddleFilter FilterAltitude = new MiddleFilterAltitude();

        MiddleFilter FilterWildPoints = new MiddleFilterWildPoints();

        SinkFilter FilterOut = new SinkFilter("./OutputB.dat");


        FilterOut.Connect(FilterWildPoints.pipe1);

        FilterWildPoints.Connect(FilterAltitude);

        FilterAltitude.Connect(FilterTemperature);

        FilterTemperature.Connect(FilterIn);


        FilterIn.start();

        FilterTemperature.start();

        FilterAltitude.start();

        FilterWildPoints.pipe1.start();

        FilterOut.start();

   } // main

} // Plumber

MiddleFilterWildPoints.java:


package systemB;

import java.nio.ByteBuffer;


public class MiddleFilterWildPoints extends MiddleFilter

{

    public MiddleFilter pipe1;

    public MiddleFilter pipe2;


    MiddleFilterWildPoints()

    {

        this.pipe1 =  new MiddleFilter();

        this.pipe2 =  new MiddleFilter();

    }

    //...


} // MiddleFilter

我对Java不太熟悉,需要此代码进行赋值,但是找不到错误。


慕尼黑5688855
浏览 155回答 2
2回答

30秒到达战场

您已声明FilterWildPoints为MiddleFilter,其中没有该 pipe1字段。而是FilterWildPoints使用以下类型声明MiddleFilterWildPoints:MiddleFilterWildPoints FilterWildPoints = new MiddleFilterWildPoints();Java编译器仅查看声明的类型。最好遵循变量名的标准Java命名约定,以小写字母开头。IEMiddleFilterWildPoints filterWildPoints = new MiddleFilterWildPoints();这样,可以更容易地区分类名和变量名。
随时随地看视频慕课网APP

相关分类

Java
我要回答