small fix
This commit is contained in:
parent
376206389f
commit
9ce32992a7
|
@ -26,17 +26,17 @@ public class ArrayInitializer {
|
|||
}
|
||||
|
||||
static String[] initializeArrayAtTimeOfDeclarationMethod1() {
|
||||
String array[] = new String[]{"Toyota", "Mercedes", "BMW", "Volkswagen", "Skoda"};
|
||||
String array[] = new String[] { "Toyota", "Mercedes", "BMW", "Volkswagen", "Skoda" };
|
||||
return array;
|
||||
}
|
||||
|
||||
static int[] initializeArrayAtTimeOfDeclarationMethod2() {
|
||||
int[] array = new int[]{1, 2, 3, 4, 5};
|
||||
int[] array = new int[] { 1, 2, 3, 4, 5 };
|
||||
return array;
|
||||
}
|
||||
|
||||
static int[] initializeArrayAtTimeOfDeclarationMethod3() {
|
||||
int array[] = {1, 2, 3, 4, 5};
|
||||
int array[] = { 1, 2, 3, 4, 5 };
|
||||
return array;
|
||||
}
|
||||
|
||||
|
@ -53,13 +53,13 @@ public class ArrayInitializer {
|
|||
}
|
||||
|
||||
static int[] initializeArrayUsingArraysCopy() {
|
||||
int array[] = {1, 2, 3, 4, 5};
|
||||
int array[] = { 1, 2, 3, 4, 5 };
|
||||
int[] copy = Arrays.copyOf(array, 5);
|
||||
return copy;
|
||||
}
|
||||
|
||||
static int[] initializeLargerArrayUsingArraysCopy() {
|
||||
int array[] = {1, 2, 3, 4, 5};
|
||||
int array[] = { 1, 2, 3, 4, 5 };
|
||||
int[] copy = Arrays.copyOf(array, 6);
|
||||
return copy;
|
||||
}
|
||||
|
@ -70,9 +70,9 @@ public class ArrayInitializer {
|
|||
Arrays.setAll(array, p -> p > 9 ? 0 : p);
|
||||
return array;
|
||||
}
|
||||
|
||||
public static char[] initializeArrayUsingArraysUtilClone() {
|
||||
char[] array = new char[] {'a', 'b', 'c'};
|
||||
|
||||
static char[] initializeArrayUsingArraysUtilClone() {
|
||||
char[] array = new char[] { 'a', 'b', 'c' };
|
||||
return ArrayUtils.clone(array);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ public class ArrayInitializerTest {
|
|||
assertArrayEquals(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, initializeArrayUsingArraysSetAll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInitializeArrayUsingArraysUtilClone_thenCorrect() {
|
||||
assertArrayEquals(new char[] { 'a', 'b', 'c' }, initializeArrayUsingArraysUtilClone());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue