Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- */
- /**
- * @author Ravinesh
- *
- */
- import java.util.*;
- public class que2_str_reverse {
- /**
- * @param args
- */
- public static String revert (String s1) {
- String rev = "";
- for (int i = s1.length() - 1 ; i >= 0; i--){
- rev += s1.charAt(i);
- }
- return rev ;
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- System.out.println("Enter the string to reverse...");
- String reversed = revert(scan.nextLine());
- System.out.println(reversed);
- scan.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment