0
Q === WAP to take String and check String is palindrome or not (String is said to palindrome if reverse of sting is same as )
import java.util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner (System.in) ; String s=sc.nextLine(); System.out.println("enter any string "); int i; char ch; String st=" "; for (i=0;i<s.length(); i++) { ch=s.charAt(i); st=ch+st; } if(st.equals(s)) { System.out.println(" palindrome "); } else {
5 odpowiedzi
0
Your code looks incomplete, please LINK the complete code.
0
And what is your question?
0
check whether sting is palindrome or not(((String is said to palindrome if reverse of sting is same as original) Ex == MAM ,ARORA,ABBA
0
Your code reverses the string.
You could check if the reversed string equals the original string.
Or loop through the string and compare current character if character at length - 1 - index.
If it is a task in a sololearn course: The output must be exactly as in the task description.