Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions week1/day2/assignments/mandatory/Palindrome.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package week1.day2.assignments.mandatory;

public class Palindrome {
//Build a logic to find the given string is palindrome or not

/*
* Pseudo Code

* a) Declare A String value as"madam"

* b) Declare another String rev value as ""
* c) Iterate over the String in reverse order
* d) Add the char into rev
* e) Compare the original String with the reversed String, if it is same then print palinDrome

* Hint: Use .equals or .equalsIgnoreCase when you compare a String
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

}
String pal="madam";
String rev="";
int k=pal.length();
//System.out.println(k);
for(int i=k-1;i>=0;i--) {
rev=rev+pal.charAt(i);
}
System.out.println(rev);

if(rev==pal)
{System.out.println("Its palindrome");
}
else
System.out.println("Not palindrome");


}
}