subject

Consider the following method, remDups, which is intended to remove duplicate consecutive elements from nums, an ArrayList of integers. For example, if nums contains {1, 2, 2, 3, 4, 3, 5, 5, 6}, then after executing remDups(nums), nums should contain {1, 2, 3, 4, 3, 5, 6}. public static void remDups(ArrayList nums)
{
for (int j = 0; j < nums. size() - 1; j++)
{
if (nums. get(j).equals(nums. get(j + 1)))
{
nums. remove(j);
j++;
}
}
}
The code does not always work as intended. Which of the following lists can be passed to remDups to show that the method does NOT work as intended?
A. {1, 1, 2, 3, 3, 4, 5}
B. {1, 2, 2, 3, 3, 4, 5}
C. {1, 2, 2, 3, 4, 4, 5}
D. {1, 2, 2, 3, 4, 5, 5}
E. {1, 2, 3, 3, 4, 5, 5}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
The “rule of 72” is used to approximate the time required for prices to double due to inflation. if the inflation rate is r%, then the rule of 72 estimates that prices will double in 72/r years. for instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. write a program to test the accuracy of this rule. for each interest rate from 1% to 20%, the program should display the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (assume prices increase at the end of each year.)
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
Which of the statements below describe the guidelines for the use of text in presentation programs? a. do not use numbered lists. b. fonts should be appropriate for your audience. c. limit the number of fonts you use to three or four. d. only use bulleted lists for sales promotions. e. select font sizes that are appropriate for your delivery method. f. use font colors that work well with your background. select all that apply
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
What type of forensic evidence was recovered during the bomb set off at the new mexico facility on the video that was similar to the evidence obtained at the boston bombings and how did the evidence allow the researchers to connect other pieces of evidence to the same bomb?
Answers: 2
question
Computers and Technology, 24.06.2019 16:50
Ideally, the backrest is tilted back slightly, so when you turn the wheel your shoulders are the seat.
Answers: 2
You know the right answer?
Consider the following method, remDups, which is intended to remove duplicate consecutive elements f...
Questions
question
English, 16.05.2021 02:50
Questions on the website: 13722361