error !!! please ignore approach 1 , fix me approach two , I am trying to make a palindrome checker !!! code in description | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

error !!! please ignore approach 1 , fix me approach two , I am trying to make a palindrome checker !!! code in description

import java.util.*; //WRITE A JAVA PROGRAM TO TAKEA WORD AS A INOUT FROM THE USER AND CHECK WHETHER ITS A PALINDROME //words to test : , MOM ,NITIN , POOP, TACOCAT , BOOB , LOOL , ETC...... //APPROACH 1 String str1= new String("BOOB"); String str2 = new String(""); for(int i=str1.length()-1;i>=0;i--){ str2 =str2+str1.charAt(i); } if (str1.length()%2!=0){ if(str1.charAt((str1.length()/2))==str2.charAt((str2.length()/2))){ for(int i =0;i>=str1.length();i++ ){ if(str1.charAt(i)==(str2.length()-1-i)){ System.out.println("Yes its a palindrome"); }else{ System.out.println("NO its not a palindrome "); } } } }else{ for(int i =0;i>=str1.length();i++ ){ if(str1.charAt(i)==(str2.length()-1-i)){ System.out.println("Yes its a palindrome"); }else{ System.out.println("NO its not a palindrome "); } } } } } // status: success -- class palindrome{ public static void main(String args[]){

9th May 2023, 7:44 AM
Shubham Swaraj 161
Shubham Swaraj 161 - avatar
3 Answers
+ 5
Share your code in separate file https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
9th May 2023, 8:38 AM
Hasnain [ACTIVE CHALLENGER]
Hasnain [ACTIVE CHALLENGER] - avatar
+ 3
Shubham Swaraj 161 Also, avoid abuse of blank lines. Use only one between logic blocks. Readable code is always better.
9th May 2023, 11:23 AM
Emerson Prado
Emerson Prado - avatar
+ 2
Shubham Swaraj 161 I think you have not shared the full code better share the code bit in question instead of writing here
9th May 2023, 8:24 AM
I am offline
I am offline - avatar