-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRevStr.java
More file actions
35 lines (35 loc) · 856 Bytes
/
RevStr.java
File metadata and controls
35 lines (35 loc) · 856 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
import java.util.*;
public class RevStr
{
String str,revs="";
void getstring()
{
Scanner as = new Scanner(System.in);
System.out.println("Enter the Word:");
str= as.nextLine();
}
void reverse(int l)
{
if(l>=0)
{
char c=str.charAt(l);
revs+=c;
reverse((l-1));
}
}
void check()
{
reverse((str.length()-1));
if(str.equalsIgnoreCase(revs)==true)
System.out.println("The Word "+str+" is a palindrome word");
else
System.out.println("The word " + str+ " is not a palindrome word!");
}
public static void main(String[] args)
{
System.out.println("\tA PALINDROME PROGRAM\n");
RevStr as1=new RevStr();
as1.getstring();
as1.check();
}
}