请问一下这个程序要怎么改啊,现在这个代码有异常。。。

public class Employee {
 private String name;
 private int age;
 private int wage;
 public Employee(){}
 public Employee(String name,int age,int wage){


  this.name=name;
  this.age=age;
  this.wage=wage;
 }
 public String getName(){
  return name;
 }
 public int getAge(){
  return age;
 }
 public int getWage(){
  return wage;
 }
 public String toString(){
  return name+","+age+","+wage;
 }
}


public class EmployeeList {
 private ArrayList<Employee>arr;
 public EmployeeList(){
  arr=new ArrayList<Employee>();
 }
 public void getEmployees(InputStream stream){
  DataInputStream in=new DataInputStream(stream);
  char ch;
  String name="";
  try {
    while((ch=in.readChar())!=','&&ch!=-1)
     name+=ch;
    arr.add(new Employee(name,in.readInt(),in.readInt()));
    //System.out.println(arr);
    name="";
  } catch (IOException e) {
   e.printStackTrace();
  } 
 }
 public ArrayList getArr(){
  return arr;
 }
}


public class TestApp {
 public static void main(String []args)throws IOException{
  EmployeeList employeelist=new EmployeeList();
  FileInputStream fin=new FileInputStream("d:\\0001\\student.txt");
  employeelist.getEmployees(fin);
  System.out.println(employeelist.getArr());
 }
 
}

TOW哈克
浏览 1332回答 1
1回答

呦呦米

可以把错误贴上来,方便分析
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java