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



Ask a Question

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. You should give more specification on exactly whe
View Tutorial          By: Abhijit at 2013-03-09 20:14:21

2. heyy dis is not working with me .. plz suggest

View Tutorial          By: sahil at 2012-10-26 11:03:41

3. very nice tutorial.. keep it up. cheers

View Tutorial          By: chanchal at 2013-01-24 06:54:23

4. Simple Codes please... I just wonder why does my p
View Tutorial          By: Joseph at 2009-11-12 05:37:50

5. Can u show how to do text to speech with servlet.
View Tutorial          By: Rotika at 2011-01-23 20:54:40

6. really helpfull :) thanks
View Tutorial          By: Jagan at 2014-12-09 10:16:56

7. i have to learn java
View Tutorial          By: md arif alam at 2013-04-15 18:30:27

8. Did you check if you are using the correct usernam
View Tutorial          By: Murugan at 2011-11-18 09:28:47

9. ma'am aiza teaches us very well.. >< i like
View Tutorial          By: chai at 2011-02-07 07:06:36

10. thank you.
View Tutorial          By: lluulnw at 2014-11-22 12:39:35