I need to combine an array of strings as below ( so as each character in the result string is a bitwise & of the characters in the input string)
String a = "10110001" String b = "01101101" String c = "10101011" String result = "00100001" Solution I came up with:
long resultLong = 0; for( String a : inputs ) { resultLong = resultLong & Long.parseLong( a ,2); } String result = Long.toBinaryString( resultLong ); The number of characters in the input string could be very long, and the above solution wouldn't work (NumberFormatException) . I couldn't get my head around how to implement this, what would be the cleanest way ?