Create a class called OurArrayList and implement the following methods. Do NOT create any auxiliary memory. Include a main method and test all your methods with appropriate examples. a. Write a method called scaleByK() that takes an ArrayList of integers as a parameter and replaces every integer of value K with K copies of itself. For example, if the list stores the values (4, 1 , 2, 0 ,3) before the method is called, it should store the values (4, 4, 4, 4, 1, 2, 2, 3, 3, 3) after the method finishes executing. Zeroes and negative numbers should be removed from the list by this method
JAVA, NOTE: PLEASE THE METHOD SHOULD USE THE INITIAL ARRAYLIST AND TO EDIT IT NOT TO CREATE A NEW ONE
Create a class called OurArrayList and implement the following methods. Do NOT create
any auxiliary memory.
Include a main method and test all your methods with appropriate examples.
a. Write a method called scaleByK() that takes an ArrayList of integers as a
parameter and replaces every integer of value K with K copies of itself. For
example, if the list stores the values (4, 1 , 2, 0 ,3) before the method is called, it
should store the values (4, 4, 4, 4, 1, 2, 2, 3, 3, 3) after the method finishes
executing. Zeroes and negative numbers should be removed from the list by this
method
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images