-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpalindrome.java
More file actions
36 lines (23 loc) · 923 Bytes
/
Copy pathpalindrome.java
File metadata and controls
36 lines (23 loc) · 923 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
32
33
34
35
36
// Palindrome number in java: A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers. It can also be a string like LOL, MADAM etc.
import java.util.*;
class palindrome
{
public static void main(String args[])
{
String inside ="abc";
String outside ="";
Scanner in = new Scanner(System.in);
System.out.println("Enter the Palindrome");
inside = in.nextLine();
System.out.println();
for(int i = inside.length()-1; i>=0;i--){
outside = outside + inside.charAt(i);
}
if(inside.equals(outside)){//Check to know the string character can become palindrome
System.out.println("The input string/number is a palindrome: "+outside);
}else{
System.err.println("Input is not palindrome ");
}
// System.out.print(outside);
}
}