Comment on Tutorial - Palindrome String in Java By Grant Braught



Comment Added by : Sandhya

Comment Added at : 2012-06-21 06:08:25

Comment on Tutorial : Palindrome String in Java By Grant Braught
The smiple easy and best way is :)
------------------------------------------------
import java.util.Scanner;
public class Palindrome {
static String str2 = "";
static String comString;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String enteredString = s.next();
comString = enteredString;
int stringLength = enteredString.length();
for (int i = stringLength - 1; i >= 0; i--) {
char currentChar = enteredString.charAt(i);
String str1 = Character.toString(currentChar);
str2 = str2.concat(str1);
}
if (str2.equals(comString)) {
System.out.println("Is Pallandrome");
} else {
System.out.println("Not a Pallandrome");
}
}
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. nice!!!!
View Tutorial          By: svk at 2013-01-17 19:59:05

2. please am in Nigeria, i need to know how to send a
View Tutorial          By: kay at 2009-10-15 03:06:10

3. i found this tutorial very useful... i need to kno
View Tutorial          By: Anonymous at 2009-04-14 21:09:20

4. i have a shimmer accelerometer(bluetooth). i need
View Tutorial          By: jason at 2012-03-22 04:05:08

5. /*Overridding & equals:--> Overriding is an
View Tutorial          By: Naveen Kumar at 2011-04-30 18:44:55

6. i was after a user interactive calendar where they
View Tutorial          By: Harry at 2011-11-17 09:01:07

7. Very good !!
View Tutorial          By: SGK at 2009-04-26 23:53:44

8. hi can u send me the complete working code for sen
View Tutorial          By: gautami at 2007-12-04 01:13:45

9. for me also The code gives the following exception
View Tutorial          By: Nilesh Agrawal at 2012-06-06 15:55:02

10. U did'nt explain super(a,B)
View Tutorial          By: Rafiqullah at 2013-12-16 10:30:41