This example will show how to shift array elements in a specified array using core java techniques.
@Test public void shift_values_in_array_with_java () { String[] shoeTypes = { "Nike", "Puma", "Converse", "Reebok", "Asics"}; String[] shoeTypesMinusNike = new String[shoeTypes.length - 1]; System.arraycopy(shoeTypes, 1, shoeTypesMinusNike, 0, shoeTypes.length - 1); logger.info(shoeTypesMinusNike); assertTrue(Arrays.binarySearch(shoeTypesMinusNike, "Nike") < 0); }
Output
[Puma, Converse, Reebok, Asics]