如何根据数字将字符串放入特定位置的数组?
public Student(String firstName, String lastName, String studentNumber, int grade){
courseTimeTable = new String[] {"Block " + courseBlock + ": " + course, "Block " + courseBlock + ": " + course};
}
public void setCourse(int block, String courseCode) {
course = courseCode;
courseBlock = block;
}
那么如何根据“courseBlock”将“课程”放入“courseTimeTable”数组
答案 0 :(得分:1)
首先需要知道courseTimeTable的最大大小。
然后你可以这样做:
courseTimeTable = new String[<maximumSize>];
courseTimeTable[courseBlock] = ...;