Reverse a string in Java

前端 未结 30 2663
礼貌的吻别
礼貌的吻别 2020-11-21 13:12

I have \"Hello World\" kept in a String variable named hi.

I need to print it, but reversed.

How can I do this? I understand there

30条回答
  •  梦毁少年i
    2020-11-21 13:58

        //Solution #1 -- Using array and charAt()
        String name = "reverse"; //String to reverse
        Character[] nameChar =  new Character[name.length()]; // Declaring a character array with length as length of the String which you want to reverse.
        for(int i=0;i

提交回复
热议问题