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. I have try this code.
Code has Run succeefu

View Tutorial          By: Avinash at 2010-06-07 05:38:26

2. Perfectly working, and able to connect database.
View Tutorial          By: satyajit at 2012-06-01 20:16:53

3. Great Article...thanks :)
View Tutorial          By: Paras Chawla at 2012-10-28 04:35:57

4. In 6th point .....there is a spelling mistake...mi
View Tutorial          By: Gnani at 2009-09-22 12:25:59

5. Hello , How could i Run java.comm on eclipse

View Tutorial          By: Fiars at 2011-04-11 04:53:45

6. Hi.
How we can create list with menuitem in

View Tutorial          By: omid at 2008-09-08 02:09:50

7. Yes it is exactly same as HTML. No change. In fact
View Tutorial          By: aathishankaran at 2008-08-03 05:22:38

8. MySQL Connector/J supports only TCP/IP connections
View Tutorial          By: Java Training Institute In Chennai at 2012-09-13 12:37:44

9. I did this exactly.
In my case, the fix.php

View Tutorial          By: Manorasa at 2010-06-29 23:32:24

10. wats the output ?
View Tutorial          By: siri at 2011-10-25 08:20:10