AF
Home
Tag
Submit Notes
Ask Anything
Login
Subscribe Us
A
ny
F
orum
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.
Follow @anyforumin
corejava-string-handling: How to reverse the String in iteration?
WAP to reverse the String in n-1 iterations. Where n is the length of input String.
corejava x 353
string-handling x 34
Posted On :
2016-06-09 22:28:41.0
Saksham Kumar
734
339
39091
3
Answers
import java.util.Scanner;
public class IterationReverse {
public static void main(String[] args) {
System.out.println("Please enter the input String");
Scanner input=new Scanner(System.in);
String string=input.nextLine();
System.out.println("Input String: "+string);
int length=string.length();
for(int i=1;i<length;i++){
System.out.print("Step: "+i+" ");
for(int j=length-1;j>=length-i;j--){
System.out.print(string.charAt(j));
}
System.out.println(string.substring(0,length-i));
}
}
}
Posted On :
2016-06-09 23:17:25
Satisfied :
1 Yes
0 No
Rishi Kumar
523
1882
49150
Reply This Thread
4
Post Answer
Please Login First to Post Answer:
Login
Answer:
anyforum.in