Using java, write a single method that takes an ArrrayList of integers as a para
ID: 3634379 • Letter: U
Question
Using java, write a single method that takes an ArrrayList of integers as a parameter and replaces every integer of value T with T copies of itself. For example, if the list stores he 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.Again, this should only be a single method. Please do not worry about test cases as i will be using my own by placing the ArrayLists as parameters, and testing under main that way, so the method should be able to take any of those ArrayLists.
Thanks again.
Explanation / Answer
Here's a method that takes in an ArrayList and returns the "updated" ArrayList. I wasn't sure if that would suffice or if the original ArrayList was supposed to be updated in the method.
Let me know if you have any questions.
Thanks,
Joe
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.