Here is a program to find out the Palindrome in Core Java
This is a basic program in Core java to understand the concept of loop and array in core java
public class Palindrome {
public static void main(String args[]){
boolean b = true;
String a = "ankit";
String []abc = a.split("");
for(int i = 0; i < abc.length ; i++){
if(abc[abc.length -i -1].equalsIgnoreCase(abc[i]) )
b=true;
else{
b = false;
break;
}
}
if(b == false){
System.out.println("NO..Its not a Palindrome ");
}
else
System.out.println("YES..Its a Palindrome");
}
}
This is a basic program in Core java to understand the concept of loop and array in core java
public class Palindrome {
public static void main(String args[]){
boolean b = true;
String a = "ankit";
String []abc = a.split("");
for(int i = 0; i < abc.length ; i++){
if(abc[abc.length -i -1].equalsIgnoreCase(abc[i]) )
b=true;
else{
b = false;
break;
}
}
if(b == false){
System.out.println("NO..Its not a Palindrome ");
}
else
System.out.println("YES..Its a Palindrome");
}
}
No comments:
Post a Comment