You are viewing a single comment's thread. Return to all comments →
Two different ways to solve this problem. Hope you will find this helpful.
import java.util.Scanner;
public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in);
String A = scan.next(); String C = scan.next(); scan.close(); //with for loop String B = ""; for (int i = A.length()-1; i >=0; i--) { B += A.charAt(i); } System.out.println(A.equals(B)? "Yes":"No"); //With String Builder StringBuilder sb = new StringBuilder(C); String reversed_String = sb.reverse().toString(); System.out.println(C.equals(reversed_String)? "Yes":"No"); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java String Reverse
You are viewing a single comment's thread. Return to all comments →
Two different ways to solve this problem. Hope you will find this helpful.
import java.util.Scanner;
public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in);
}