Reverse string method

后端 未结 6 1683
暗喜
暗喜 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:55

    public class Dowhile {
      package dowhile;
      public static void main(String[] args) {
         // TODO code application logic here
         String message="i love java programming";
         int msglength = message.length();
    
         int index=msglength-1;
         while(index>=0)
         {
            System.out.print(message.charAt(index));
            index--;
         }  
      }
    }
    

提交回复
热议问题