Dain1234 / Java-Programming

0 stars 0 forks source link

Reverse Strring #24

Open Dain1234 opened 1 year ago

Dain1234 commented 1 year ago

package com.dain.logics;

import java.util.Scanner;

public class reversestrin {

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter string to reverse");
    String name = sc.nextLine();
    String Empty = " ";
    int length = name.length();
    for (int i = length-1; i >= 0; --i) {
        Empty = Empty + name.charAt(i);
    }
    System.out.println(Empty);

}

}