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



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. Great stuff, learned more from this example than r
View Tutorial          By: David Bandelin at 2011-03-22 07:10:38

2. simple way friends:
public class palindrome

View Tutorial          By: Manoj at 2013-01-07 02:18:00

3. i run this program. its not showing any runtime or
View Tutorial          By: anand sp at 2011-03-07 10:11:37

4. it's very good to understand...and it is helpful f
View Tutorial          By: Rakesh at 2009-12-26 00:14:59

5. I need full code for sending SMS. Please send to m
View Tutorial          By: Ramesh at 2014-05-21 06:54:52

6. nice example..thanx i was havin trouble wid timers
View Tutorial          By: gunjan at 2008-06-02 03:06:17

7. Using ForwardAction for Integration is Good, Which
View Tutorial          By: Ramesh Ram at 2013-06-05 17:57:25

8. nice work.......
View Tutorial          By: sukirti at 2011-05-06 16:30:19

9. Hi everyone!
Pls I dnt know hot to configur

View Tutorial          By: DSE90 at 2010-02-12 12:05:57

10. thanks for this tutorial! it's very useful
View Tutorial          By: Miguel at 2011-06-26 21:15:00