Saturday, August 23, 2014

Java : Program to reversing a string


public class ReverseString {

/**
* @param args
*/
public static void main(String[] args) {

//String[] name = new String[10];
String name , rev = "";

Scanner in = new Scanner(System.in);
System.out.println("Enter the string for reversal :- ");
name = in.nextLine();

int len = name.length();

for(int i = len-1;i>=0;i--){
rev = rev + name.charAt(i);
}
System.out.println(rev);
}


}

No comments:

Post a Comment

Testing a New Product: Essential Information Software Testers Must Gather in the AI Era

    Learn what information software testers must gather before starting testing a new product, including AI, automation, compatibility, and ...