+ 7

How to print reverse of your name in java ?

I know that we can print reverse of a no. in java by palindrome program but i have no idea bout the name...

1st Mar 2018, 3:31 AM
Akshat Agarwal
Akshat Agarwal - avatar
5 Respostas
+ 25
using reverse() from library
1st Mar 2018, 3:56 AM
Shams Awais
Shams Awais - avatar
+ 19
use .charAt(index no); 1)run a loop for n=length of string-1 to n=0 2)add Stringname.charAt(n) to an empty String str=""; , declared outside of loop 3)print str //hope u got it 👍
1st Mar 2018, 3:54 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
https://code.sololearn.com/c45IEICyKn95/#java import java.util.Scanner; public class Program { public static void main(String[] args) { // Obtain input from user Scanner scnr = new Scanner(System.in); // Create a StringBuilder object and use our input StringBuilder myString = new StringBuilder(scnr.nextLine().toString()); // Print name forward. System.out.println("Forward: " + myString); // Print name backwards. System.out.println("Backward: " + myString.reverse()); } }
1st Mar 2018, 3:46 AM
Fata1 Err0r
Fata1 Err0r - avatar
+ 5
Sorry, just read the description. :D Not sure exactly what you're wanting, but maybe that'll help you out.
1st Mar 2018, 3:48 AM
Fata1 Err0r
Fata1 Err0r - avatar
0
This code can be used to obtain the reverse of a name as well as to check whether the given name is a palindrome https://code.sololearn.com/cUd4r6SiLzV6/?ref=app
23rd Mar 2018, 1:23 AM
D Janapriya
D Janapriya - avatar