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
24 changes: 24 additions & 0 deletions palindromeTest_simple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.util.Scanner;

class palindromeTest_simple{
public static void main(String[] args){

Scanner in = new Scanner(System.in);
StringBuffer testString = new StringBuffer();
System.out.println("Enter string to check: ");
testString.append(in.nextLine());
palindromeTest_simple check = new palindromeTest_simple();
check.checkPalindrome(testString);
}


void checkPalindrome(StringBuffer testString){
StringBuffer testReverse = new StringBuffer(testString);
testReverse.reverse();
if ((testString.toString().equals(testReverse.toString()))== true)
System.out.println("Is a palindrome");
else
System.out.println("Not a palindrome");
}

}