このメソッドから配列リストを返そうとしています
import java.io.*;
import java.util.*;
/** The class reader read the file 2RainfallDataLanc.txt and stores is as an ArrayList.
* It also parses the variables within the file by white spaces, making variables accessible.
*
*/
public class reader {
public ArrayList<String[]> getRows(){
try {
BufferedReader reader = new BufferedReader(new FileReader("2RainfallDataLanc.txt"));
String line = null;
ArrayList<String[]> rows = new ArrayList<String[]>();
while((line=reader.readLine())!=null)
{String[] row = line.split("\\s+");
rows.add(row);
}
for (String[] row : rows) {
System.out.println(Arrays.toString(row));
return rows;
}
} catch (IOException e) {
}
return null;
}
}
別のクラスで使用したいので。現在、2 番目のクラスは次のようになっています。
public class mean extends reader{
public static void main(String[] args) {
reader newarray = new reader();
}
}
誰かが私が間違っていることを教えてもらえますか? 行を返そうとすると、void メソッドは値を返すことができないというエラー メッセージが表示されます。