U2p8.java

import java.util.*; public class u2p8 { public static void main(String []args) { String word,rev=""; Scanner sc=new Scanner(System.in); System.out.println("Enter String:"); word=sc.nextLine(); for(int i=word.length()-1;i>=0;i--) { rev=rev+word.charAt(i); System.out.println(rev+"\n"); rev=""; } } } /*in this program i have used the String method "charAt(int index)" this method returns the character at the specified index.*/

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.