-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractical_09.java
More file actions
31 lines (27 loc) · 831 Bytes
/
Practical_09.java
File metadata and controls
31 lines (27 loc) · 831 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
/* Question := Write a program to find that given number or string is palindrome or not. */
import java.util.Scanner;
public class Practical_09 {
static void checkPalindrome(String s) {
String r = "";
for (int i = s.length() - 1; i >= 0; i--) {
r = r + s.charAt(i);
}
if(s.equals(r)) {
System.out.println(s + " is Palindrome.");
}
else {
System.out.println(s + " is not Palindrome.");
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Number or string := ");
String s = sc.next();
checkPalindrome(s);
}
}
/* Output :=
Enter Number or string :=
mom
mom is Palindrome.
*/