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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -