Check if String is Palindrome in Java
public class Test { public static void main(String[] args) { String str = “racecar”; System.out.println(str.equals(new StringBuilder(str).reverse().toString())); } } Output: true We can do the same with the StringBuffer class since it also has the reverse() method. Using the for loop public class Test { public static void main(String[] args) { String str = “racecar”;…
Read More Check if String is Palindrome in Java