1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
eduard
3 years ago
11

Write a method called removeInRange that accepts four parameters: an ArrayList of integers, an element value, a starting index,

and an ending index. The method's behavior is to remove all occurrences of the given element that appear in the list between the starting index (inclusive) and the ending index (exclusive). Other values and occurrences of the given value that appear outside the given index range are not affected. For example, for the list [0, 0, 2, 0, 4, 0, 6, 0, 8, 0, 10, 0, 12, 0, 14, 0, 16], a call of removeInRange(list, 0, 5, 13); should produce the list [0, 0, 2, 0, 4, 6, 8, 10, 12, 0, 14, 0, 16]. Notice that the zeros located at indices betwee
Computers and Technology
1 answer:
Murrr4er [49]3 years ago
7 0

Answer:

public static void removeInRange(List<Integer> list, int value, int start, int end) {

       for (int i = end - 1; i >= start; i--) {

           if (list.get(i) == value) {

               list.remove(i);

           }

       }

       System.out.println(list);

   }

Explanation:

- Create a method named <em>removeInRange</em> that takes four parameters, a list, an integer number, a starting index and an ending index

- Inside the method, initialize a <u>for loop</u> that iterates between starting index and ending index

- If any number between these ranges is equal to the given <em>value</em>, then remove that value from the list, using <u>remove</u> method

- When the loop is done, print the new list

You might be interested in
NEED HELP RIGHT NOW!!! Which of the following is the definition of a privacy policy? * 5 points - A legal document that an app o
Marina86 [1]

Answer:

A legal document that an app or a website must provide to describe the rules the company and users must obey when they use the app.

6 0
3 years ago
onsider the following program: Peform a total of six exercises. Select one exercise from each of the following areas: hips and l
Leviafan [203]

Answer:

Beginner

Explanation:

A program like this is ideal for a beginning exerciser due to the high number of repetitions and the sets are not much.

Cheers

3 0
3 years ago
Which of the following for-loop headers results in equivalent numbers of iterations: A. for (int q = 1; q &lt;= 100; q++) B. for
vladimir2022 [97]

Answer:

b

Explanation:

C and D have equivalent iterations

C:       D:

99    990

90      900

81      810

72      720

63      630

54      540

45      450

36      360

27      270

18      180

9       90

8 0
3 years ago
En la historia del Computador porque se caracteriza la primera generación? *
Nadusha1986 [10]

D. Por el uso de tubos de vacio.

8 0
3 years ago
Call of duty vanguard, war zone , fornite, gta what’s your favorite
tia_tia [17]
Warzone easily but gta a close second
8 0
3 years ago
Other questions:
  • A _____________ is a method of controlled entry into a facility and provides access to secure areas such as a research lab or da
    10·1 answer
  • ________ work(s) by using radio waves to communicate with radio antennas placed within adjacent geographic areas.
    8·1 answer
  • Technician A says that the push rod connects to a pivoting component mounted at the top of the cylinder head called the camshaft
    14·2 answers
  • What is output? <br> Print (12 % 5)<br><br> Answer <br> 0<br> 5<br> 2<br> 1
    12·2 answers
  • To under a clip art you must do the following.
    14·1 answer
  • Explain how each of the five types of prewriting assist a writer in getting started. please make it short.
    15·1 answer
  • Professionalism is defined as what?<br> ASAP PLEASE!
    11·1 answer
  • Write a program that uses a while loop to calculate and print the multiples of 3 from 3 to 21. Your program should print each nu
    11·1 answer
  • What are some catchy names for computer basics that you would put on a childrens poster?
    9·1 answer
  • What does a companys code of ethics cover
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!