2 回答

TA貢獻1805條經驗 獲得超10個贊
import java.io.*;
public class Collect {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
File f=new File("c:\\france.txt");
RandomAccessFile mm = new RandomAccessFile(f,"rw");
Item[] qq= new Item[1000];
for (int i = 0; i < 1000; i++) {
qq[i] = new Item();
}
for (int h = 0; h < 10; h++) {
qq[h].title=mm.readLine();
qq[h].content=mm.readLine()+"\n"+mm.readLine()+"\n"+mm.readLine();
qq[h].getInfo();
}
}
}//此處再加一個大括號,并且不能在最后加大括號,除非你把下面的類當成靜態內部類
class Item{
String title;
String content;
public void getInfo(){
System.out.println(title);
System.out.println(content);
}
}
添加回答
舉報