Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with XOR

807606Mar 26 2007 — edited Mar 27 2007
hello.
I'm trying to XOR 2 string like this:
char[] str1 = "AAAABBBB";
char[] str2 = "BBBBBBBB";

static public char[] xor ( char[] a, char[] b )
       {
            int length = Math.min (a.length, b.length );
            char[] result = new char[length];
            for ( int i=0; i<length ; i++ )
            {
                result[i] = (char) ( a[i] ^ b[i] );
            }
            return result;
      }
The result would be AAAA, right?
Instead, if i print the operation a[i] ^ b, i get 33330000, where this values come from, doesn't the xor operation return 1 or 0 ?
Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2007
Added on Mar 26 2007
19 comments
198 views