Write a java program to String Reverse ?


package com.javalschool;

public class ReverseString {

public static void Reverse(String s)
{
char[] c = s.toCharArray();
String stringreverse="";
for(int i=c.length-1;i>=0;i--)
{
stringreverse+=c[i];

}
System.out.println(stringreverse);

}
public static void main(String[] args) {

ReverseString.Reverse("javalschool");

}

}


output:


loohcslavaj

No comments:

Post a Comment