Hii guys, I am newbie java learner. I was stucked in reverse a string method. I was used for loop to reverse a string. But it’s not working. Please someone tell me what happened in my code.
Hi.
length
will return 5 so in your loop you should start at length - 1
;
I would also maybe use the >= condition should you need to reach the item indexed 0.
1 Like
Also, you are actually reversing an array there. Not a String. In Java, String is its own class. This is what a String literal looks like: "some string"
1 Like