1) I'm going to read two character arrays. These contain only numbers
2) How can i add the numbers which are in those two character arrays?
To be more simple, Use for loop to iterate through array ( assuming 2 array has same size) and do arthmetic operation (+ , - or watever) by using the index of the array , say int newCH = ch1[i] + ch2[i] ;
Note this does automatic casting to int and all arthmetic operation on prmitive types leads to only "int"
3) And again, how can i store the sum result into another character array?
For this , get the int newCH to cast to char to store in char array lile ch3[i]= (char) newCH. note an explicit cast is required for primitive types in JAVA.
Other option may be convert to Wrapper classes and let that take care of casting.
Joined: Sep 02, 2008
I already did like that,
ch1 has 1,2,3,4
ch2 has 9,8,8,8
int n = ch1[i]+ch2[i];
ch[i] = (char)n;