Reverse a String without using builtin Functions
import javax.swing.JOptionPane;
import org.apache.commons.lang3.StringUtils;
public class Reverse_str
{
public static void main(String[] args)
{
String sStr=JOptionPane.showInputDialog("Enetr a str");
String sRes="";
for (int i=sStr.length() ;i>=0;i--)
{
sRes=sRes+StringUtils.mid(sStr, i, 1);
}
System.out.print(sRes);
}
}
{
String sStr=JOptionPane.showInputDialog("Enetr a str");
String sRes="";
for (int i=sStr.length() ;i>=0;i--)
{
sRes=sRes+StringUtils.mid(sStr, i, 1);
}
System.out.print(sRes);
}
}
No comments:
Post a Comment