Question: Method removeZeros: Write a method removeZeros that takes an array of integers as a parameter and returns a new array with the same contents except

Method removeZeros:
Write a method removeZeros that takes an array of integers as a parameter and returns a new
array with the same contents except the zeroes are gone.
Examples:
removeZeros (new int []{1,-2,3}) returns {1,-2,3}
removeZeros (new int []{1,0,0}) returns {1}
removeZeros(new int []{1,0,-2,0,3}) returns {1,-2,3}
Note 1: You can use the above examples in your main to check the methods works as intended.
Note 2: You can assume a legit input to the method, so no need to check for input correctness.
Tip 1: This method returns things, that means to check it you need to call it and store or print
result.
Tip 2: In java you must know the length of array you are declaring. Can you do it without
counting zeros first?
 Method removeZeros: Write a method removeZeros that takes an array of

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!