//when i run the program nothing prints. its like an infinite loop on //on the entering of my string console. //Write a Java program that accepts the input of a string from the console //and reverses it using recursion. Print the result after the string is //reversed.
import java.util.Scanner;
public class ReverseTry {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter a sentence and I will reverse it");
        reverseLine(input);
    }
    public static Scanner reverseLine(Scanner input) {
        if (!input.hasNextLine()) {
            return input;
        } else {
            //String word = input.nextLine();
            //return reverseLine(input) + " " + word;
            String line = input.nextLine();
            reverseLine(input);
            System.out.println(line);
        }
        return input;
    }
}
 
     
     
    