我正在systemB\Plumber.java:44: error: cannot find symbol FilterOut.Connect(FilterWildPoints.pipe1); ^symbol: variable pipe1location: variable FilterWildPoints of type MiddleFiltersystemB\Plumber.java:56: error: cannot find symbol FilterWildPoints.pipe1.start(); ^symbol: variable pipe1location: variable FilterWildPoints of type MiddleFilter2 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} // PlumberMiddleFilterWildPoints.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不太熟悉,需要此代码进行赋值,但是找不到错误。
2 回答
30秒到达战场
TA贡献1828条经验 获得超6个赞
您已声明FilterWildPoints
为MiddleFilter
,其中没有该 pipe1
字段。
而是FilterWildPoints
使用以下类型声明MiddleFilterWildPoints
:
MiddleFilterWildPoints FilterWildPoints = new MiddleFilterWildPoints();
Java编译器仅查看声明的类型。
最好遵循变量名的标准Java命名约定,以小写字母开头。IE
MiddleFilterWildPoints filterWildPoints = new MiddleFilterWildPoints();
这样,可以更容易地区分类名和变量名。
添加回答
举报
0/150
提交
取消