unexpected type error

The problem is here:

myStr.charAt(j) += reversed;

The left-hand-side is a value. Not a variable. That’s why you can’t to a += to it.

Although it defeats the purpose of learning how do it the hard way, you can do it like this:

myStr = new StringBuffer(myStr).reverse().toString();

Leave a Comment