Java examples for java.lang:int Array
make Xor On int Arrays
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int[] values1 = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; int[] values2 = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; System.out.println(java.util.Arrays.toString(makeXorOnArrays( values1, values2)));//w ww . j av a 2 s . c o m } public static int[] makeXorOnArrays(int[] values1, int[] values2) { if (values1.length != values2.length) { throw new RuntimeException(String.format( "Arrays are not the same size [%s != %s]", values1.length, values2.length)); } int[] result = new int[values1.length]; for (int i = 0; i < result.length; i++) { result[i] = makeXor(values1[i], values2[i]); } return result; } public static int makeXor(int value1, int value2) { return value1 ^ value2; } }