-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPalindromeTest_Logic.java
More file actions
31 lines (24 loc) · 884 Bytes
/
PalindromeTest_Logic.java
File metadata and controls
31 lines (24 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
class PalindromeTest_Logic{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String testString = new String();
System.out.println("Enter string to check: ");
testString =in.nextLine();
PalindromeTest_Logic check = new PalindromeTest_Logic();
check.checkPalindrome(testString);
}
void checkPalindrome(String testString){
char[] testReverse_temp = new char[testString.length()];
//int stringLength = testString.length();
//int temp_stringLength = testString.length();
for (int i=testString.length()-1, j=0; i>=0 ; i--, j++){
testReverse_temp[j] = testString.charAt(i);
}
String testReverse = new String (testReverse_temp);
if ((testString.equals(testReverse))== true)
System.out.println("Is a palindrome");
else
System.out.println("Not a palindrome");
}
}