i dont know what mistake i have done here i could run the prog but i am not getting the o/p so guys pls help me and this is the coding if any corrections is need pls let me know and if possible change and send me the correct prog
coding:
import java.util.*;
import org.apache.commons.lang.StringUtils;
public class reverse
{
public static void main(String args[])
{
String original="hi how are you", reverse ="",nonrecurse=" ",delimitedReverse="";
Scanner in = new Scanner(System.in);
// System.out.println("Enter a string to reverse");
// original = in.nextLine();
//int length = original.length();
// reverse=reverseMe_recursion(original);
//=reverseMe_nonrecursion(original);
rev(original);
// for ( int i = length - 1 ; i >= 0 ; i-- )
// reverse = reverse + original.charAt(i);
//delimitedReverse = StringUtils.reverseDelimited(original, ' ');
System.out.println("Reverse of string using recursion is: "+reverse);
System.out.println("Reverse of string using nonrecursion is: "+nonrecurse);
System.out.println("The delimited Reverse string: " +delimitedReverse);
}
static String reverseMe_recursion(String s) {
if(s.length() == 0)
return "";
return s.charAt(s.length() - 1) + reverseMe_recursion(s.substring(0,s.length()-1));
}
static String reverseMe_nonrecursion(String s) {
StringBuilder sb = new StringBuilder();
for(int i = s.length() - 1; i >= 0; --i)
sb.append(s.charAt(i));
return sb.toString();
}
public static void rev(String original)
{
try
{
for(int i=0;i<original.length();i++)
{
if(original.charAt(i)==i)
{
int count = 0;
count++;
}
}
}
catch(Exception e)
{
}
}
}