【发布时间】:2013-10-03 01:38:22
【问题描述】:
我正在尝试使用此 wavRead(filename),但收到消息 cannot make a static reference to a non static method。
我可以简单地将其设为静态并解决我的问题,但是如果不走那条路线怎么办。我想保持方法非静态。
这里有一些代码让你看看发生了什么:
public class Sound {
double [] mySamples;
public static void main(String[] args){
String filename = null;
System.out.println("Type the filename you wish to act upon.");
Scanner scanIn = new Scanner(System.in);
filename = scanIn.next();
wavRead(filename);
}
public void wavRead(java.lang.String fileName){
mySamples = WavIO.read(fileName);
}
【问题讨论】: