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. gud example, we welcome you
View Tutorial          By: jasim Khalid almurakh meherbani at 2010-09-20 03:14:25

2. ya its correct but tell me where is main method???
View Tutorial          By: kashiNATH MOKASHI at 2011-08-20 05:33:19

3. Thanks.. grt example
Also... If the type ar

View Tutorial          By: Shahid at 2011-12-20 10:26:22

4. can you help me in codings for get an output like
View Tutorial          By: Sudhar at 2011-08-24 05:47:53

5. nice one !!! just keep it .. i have learn a lot..
View Tutorial          By: dondon at 2011-07-27 04:43:40

6. Thanks very much....its very simple explained.....
View Tutorial          By: nizam at 2012-12-17 09:43:11

7. could u help me i want to integrate the paypal sys
View Tutorial          By: Anand at 2011-01-17 21:59:25

8. EXACTLY COPIED BY "C PROGRAMMING" by DEN
View Tutorial          By: Aashish at 2012-06-06 17:56:36

9. hello,
i have to connect the crystal report

View Tutorial          By: shanmugaraj at 2010-03-03 04:08:30

10. Hi Along with your provided code below, if we are
View Tutorial          By: Roshan at 2011-05-02 12:06:27