I need to create a method compact that can remove all zeroes from an array and leave the order of other elements unchanged, but without creating a new array. The method must actually remove all zeroes, not just print out the other elements, and it should only use one private array. So 0, 9, 7, 0, 0, 23, 4, 0 would turn into 9, 7, 23, 4. I've been stuck since everything I have have found online says it is impossible to remove elements from an array without creating a new array, so any help would be much appreciated.
aelajj 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
ObSys 56 Junior Poster
stultuske 1,116 Posting Maven Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
ObSys 56 Junior Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.