public static void AddTeam(Scanner in) throws Exception {
Scanner in1 = new Scanner(System.in);
System.out.print("\nEnter team leader name: ");
String name = in1.nextLine();
System.out.print("Enter team leader ID: ");
String id = in1.nextLine();
System.out.print("\naaaaaaaaaaaaaaa");//想在Test里判断一下是否走到这里
ArrayList<FFPerson> teamM = new ArrayList<>();
try {
teamM.add(new FFPerson(name, Integer.parseInt(id)));
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print("\nbbbbbbbbbbbbbbbb");//想在Test里判断一下是否走到这里
FFTeam team = new FFTeam();
team.setTeamLeader(0);
team.setTeamList(teamM);
System.out.print("\nccccccccccccccc");//想在Test里判断一下是否走到这里
fireTeams.add(team);//在这样卡住了 报错是:java.lang.NullPointerException
System.out.println("Team created successfully.");
}
//////////////////////////////
//测试代码如下:
@Test
public void AddTeamTest1() throws Exception {
Scanner in = null;
FFApp.AddTeam(in);
System.out.println(fireTeams);
}
这是运行结果