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. Thanks, you save my day!
View Tutorial          By: ivex at 2015-06-25 20:20:07

2. it help me lot 2 understand what is struts-config
View Tutorial          By: Amit Tomar at 2010-11-27 09:27:15

3. i want to the out put is
calander

View Tutorial          By: sampath at 2011-07-18 08:30:01

4. please provide Example instanceof With Collection
View Tutorial          By: siddardha at 2010-08-18 00:30:38

5. Great Thanks
View Tutorial          By: seedimani at 2009-09-16 01:27:26

6. Hi , it was nice tutorial to understand the differ
View Tutorial          By: jagan at 2014-06-05 05:13:59

7. Thank you so much....
I am going to have ja

View Tutorial          By: Mehrnoosh at 2013-06-09 16:50:23

8. i m a student of Bahria university,Pakistan.and th
View Tutorial          By: Rao Waseem at 2011-05-14 12:55:53

9. Very usefull info.. Thank alot
View Tutorial          By: Srikanth at 2012-09-04 15:44:30

10. @Sonal, as long as the image is stored in a server
View Tutorial          By: alex at 2012-11-07 07:25:40