Program Discussion :: Strings
334 / 60
Write program to reverse of string without using any loop.
Answer:
import java.util.*;
public class Reverse
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a string: ");
String str=sc.nextLine();
StringBuffer sb=new StringBuffer(str);
System.out.println("Reverse of the string is: "+sb.reverse());
}
}
Asked In ::
Language:
Siddhartha Paul
19 Jun, 2019 2:16 PM
import java.util.*;
public class Reverse
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a string: ");
String str=sc.nextLine();
StringBuffer sb=new StringBuffer(str);
System.out.println("Reverse of the string is: "+sb.reverse());
}
}