import java.util.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); System.out.println("Enter a string"); String str=sc.nextLine(); String rev = ""; for(int i=str.length()-1;i>=0;i--){ rev = rev + str.charAt(i); } System.out.println(rev); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter