+ 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...
5 Respostas
+ 25
using reverse() from library
+ 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 👍
+ 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());
}
}
+ 5
Sorry, just read the description. :D Not sure exactly what you're wanting, but maybe that'll help you out.
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