XOR of two Binary Strings | Java Implementation to find the XOR of the two Binary Strings ; Function to find the XOR of the two Binary Strings ; Loop to iterate over the Binary Strings ; If the Character matches ; Driver Code
import java . io . * ; class GFG { static String xoring ( String a , String b , int n ) { String ans = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( a . charAt ( i ) == b . charAt ( i ) ) ans += "0" ; else ans += "1" ; } return ans ; } public static void main ( String [ ] args ) { String a = "1010" ; String b = "1101" ; int n = a . length ( ) ; String c = xoring ( a , b , n ) ; System . out . println ( c ) ; } }