Learnstreet java lesson 3 part 8, reversing a string -
question asks reverse characters "mug" set string "gum" tried suggested
"mug".charat(2) + "mug".charat(1) + "mug".charat(0)
once input says incorrect
your code results integer 329
, result of char plus char integer.
to reverse string, may use stringbuilder
or stringbuffer
's reverse
method:
new stringbuilder("mug").reverse().tostring()
or
new stringbuffer("mug").reverse().tostring()
Comments
Post a Comment