I'm doing an assignment that takes two unlimited unassigned integers, represented as strings, and adds them up. My add method is giving me grief. I keep getting this error and don't know why.
Here's the part of the code giving me trouble:
for(int i = 0; i <= cap; i = i + 1){
number.charAt(i) = number.charAt(i) + secondNumber.charAt(i);
//loop checks to see if the current number at i is > or = to 10
//if it is it subtracts ten from the character at i and adds 1 to the
character at i + 1
if(number.charAt(i) >= 10){
number.charAt(i) = number.charAt(i) - 10;
number.charAt(i + 1) = number.charAt(i + 1) + 1;
}
}
Here's the error:
UUI.java:25: error: unexpected type
number.charAt(i) = number.charAt(i) + secondNumber.charAt(i);
^
required: variable
found: value
I get the error three times whenever I use the charAt method