Reverse string method

后端 未结 6 1618
暗喜
暗喜 2021-01-20 00:25

I am trying to solve the following problem but how do write the method that accepts String as an argument?

Write a method named printReverse

6条回答
  •  被撕碎了的回忆
    2021-01-20 00:50

    private static void printReverse (String org)
    {
    
      StringBuffer buffer = new StringBuffer(org);
      String reversedStr = buffer.reverse().toString();
      System.out.println("The reverse of the string \""
                + str + "\" is \"" + reversedStr + "\".");
    
    }
    

    in the main call the function

    printReverse(original);
    

提交回复
热议问题