[mv-0-to-end-array] changes for comments
This commit is contained in:
parent
e8b27416d7
commit
7b115b3a26
|
@ -7,11 +7,11 @@ import java.util.Arrays;
|
|||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
public class MoveZeroesToTheEndOfAnArrayUnitTest {
|
||||
static final int[] EXPECTED = new int[] { 1, 2, 3, 4, 0, 0 };
|
||||
private static final int[] EXPECTED = new int[] { 42, 2, 3, 4, 0, 0 };
|
||||
|
||||
@Test
|
||||
void whenCreatingANewArrayAndCopyingValues_thenGetTheExpectedResult() {
|
||||
int[] array = new int[] { 1, 2, 0, 3, 4, 0 };
|
||||
int[] array = new int[] { 42, 2, 0, 3, 4, 0 };
|
||||
int[] result = new int[array.length];
|
||||
int idx = 0;
|
||||
for (int n : array) {
|
||||
|
@ -24,13 +24,12 @@ public class MoveZeroesToTheEndOfAnArrayUnitTest {
|
|||
|
||||
@Test
|
||||
void whenMovingZeroInTheOriginalArray_thenGetTheExpectedResult() {
|
||||
int[] array = new int[] { 1, 2, 0, 3, 4, 0 };
|
||||
int[] array = new int[] { 42, 2, 0, 3, 4, 0 };
|
||||
int idx = 0;
|
||||
for (int n : array) {
|
||||
if (n != 0) {
|
||||
array[idx++] = n;
|
||||
}
|
||||
System.out.println(Arrays.toString(array));
|
||||
}
|
||||
while (idx < array.length) {
|
||||
array[idx++] = 0;
|
||||
|
|
Loading…
Reference in New Issue