My question seems very simple, but I've tried searching for a specific answer and have found none. I've found answers similar to what I've been looking for, but they've only managed to confuse me further:
All I want to do is add two character arrays and print the resulting array. The project deals with binary numbers, but I'll deal with base-2 arithmetic later, so just pretend they're base-10 numbers.
char[] array = {'1', '0', '0', '1'};
char[] array2 = {'1', '1', '0', '0'};
char[] sum = new char[4];
for(i=0; i < 4; i++){
sum[i] = char(array[i] + array2[i]);
System.out.print(sum[i] + " ");
}
My answer is "b''b" when I run it, so it seems some ASCII conversion is happening I guess? My expected answer should be "2101" and I realize the problem is in my casts, I just don't know how to proceed. Sum must remain a character array as part of the program's parameters.
EDIT: I KNOW using an int array for sum would solve this problem. As I stated in my original post, sum MUST remain a character array as part of the parameters of this project.
int[]instead?