title: How do I remove certain elements from an array in Java?
body: <p>If I have an array of numbers, say 5, 6, 8, 1, 0, 5, 0, 0, 0, so the length of my array is 9, and I want to shorten the array so that all the elements equal to 0 are removed from the end until the first non-zero element is reached, how do I do that?  In short, I want my new array to be 5, 6, 8, 1, 0, 5. </p>