Question: The following dropStudent method from listing 10.6 contains two errors. What are they? 01 public void dropStudent(String student) { 02 int locationToZap = -1; 03

The following dropStudent method from listing 10.6 contains two errors. What are they?

01 public void dropStudent(String student) {

02 int locationToZap = -1;

03 int currLoc = 0;

04 for (currLoc = 0; currLoc < numberOfStudents && locationToZap == -1; currLoc++) {

05 if (students[currLoc] == student) {

06 locationToZap = currLoc;

07 }

08 }

09 if (locationToZap == -1) return;

10 for (currLoc = locationToZap; currLoc < numberOfStudents; currLoc++) {

11 students[currLoc] = students[currLoc + 1];

12 }

13 numberOfStudents--;

14 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!