我刚开始学习 Java,目标是为 Android 制作游戏。我正在参加在线课程,在那里我获得了一项任务,然后是某种评估。
这是我到目前为止所做的:
public String[] pie;
public Scanner x;
public String[] name;
public String[] name1;
public String[] name2;
public int[] year;
public int[] numb;
public String[] language;
public boolean[] read;
public int[] rating;
public void openfile(){
try{x = new Scanner(new File("Raamatukogu.txt"));}
catch(Exception e){
System.out.println("no file was found");}}
public void readfil(){
while(x.hasNext()){
String rida = x.nextLine();
pie = rida.split("#");
for(int i = 0; i < pie.length ; i++){
我想做的是在我的代码中添加这样的东西,但是自动化:
name[0] = pie[0]
name1[0] = pie[1]
name2[0] = pie[2]
year[0] = pie[3]
numb[0] = pie[4]
language[0] = pie[5]
read[0] = pie[6]
rating[0] = pie[7]
name[1] = pie[8]
name1[1] = pie[9]
name2[1] = pie[10]
year[1] = pie[11]
numb[1] = pie[12]
language[1] = pie[13]
read[1] = pie[14]
rating[1] = pie[15]
name[2] = pie[16]
name1[2] = pie[17]
...}
先感谢您!