Computer Science, asked by ratnavsec, 1 month ago

write a program in java to take a string from the user and reverse the string. for example :- input : i love you output: you love i
please help:))​ ​

Answers

Answered by crankybirds30
0

Answer:

package Edureka;

import java.util.*;

public class StringReverse{

public static void main(String args[]) {

String initial, rev="";

Scanner in=new Scanner(System.in);

System.out.println("Enter the string to reverse");

initial=in.nextLine();

int length=initial.length();

for(int i=length-1;i>=0;i--)

rev=rev+initial.charAt(i);

System.out.println("Reversed string: "+rev);

}

}

Answered by crankybirds30
0

Answer:

package Edureka;

import java.util.*;

public class StringReverse{

public static void main(String args[]) {

String initial, rev="";

Scanner in=new Scanner(System.in);

System.out.println("Enter the string to reverse");

initial=in.nextLine();

int length=initial.length();

for(int i=length-1;i>=0;i--)

rev=rev+initial.charAt(i);

System.out.println("Reversed string: "+rev);

}

}

Similar questions