我正在尝试使用此方法创建“运动”类的两个实例。该方法传入一个数组,其中包含有关类的信息,然后将其发送到要创建的构造函数。
但是,我不确定如何在给定代码的情况下引用实例 1 或 2。
public static void seperateValues(String sportDetail) {
String[] sportDetails = sportDetail.split(",");
System.out.println("Adding new sport to the Sport collection");
System.out.println(sportDetail);
/*
for(int i=0; i<sportDetails.length; i++) //just used for testing whether it was splitting correctly {
System.out.println(sportDetails[i]);
}*/
//name,usagefee,insurance,affiliationfees, then court numbers
//Tennis,44,10,93,10,11,12,13,14,15,16
int vlength;
vlength = sportDetail.length();
new Sport(sportDetails); //this static methods loops twice, giving tennis and baseball
System.out.println(name); //this lists tennis and baseball respectively
}