Comment on Tutorial - Palindrome String in Java By Grant Braught



Comment Added by : Bhaskar.pg

Comment Added at : 2014-05-29 12:39:52

Comment on Tutorial : Palindrome String in Java By Grant Braught
import java.util.*;

class Pstring
{
public static void main(String args[])
{
String original, reverse="";
Scanner in = new Scanner(System.in);

System.out.println("Enter a string to check if it is a palindrome");
original = in.nextLine();

int length = original.length();

for ( int i = length - 1 ; i >= 0 ; i-- )
reverse = reverse + original.charAt(i);

if (original.equals(reverse))
System.out.println("Entered string is a palindrome.");
else
System.out.println("Entered string is not a palindrome.");

}
}


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. hey..
shouldn't the 2nd java code have an o

View Tutorial          By: izzie at 2010-04-06 11:34:34

2. i want some explanation about struts form field va
View Tutorial          By: ramizah at 2007-10-03 23:40:11

3. import java.io.*;
import java.util.Stack;
View Tutorial          By: jack&jill at 2011-07-26 06:40:32

4. Dear admin,
your Recaptcha design is not go

View Tutorial          By: surendra kumar sharma at 2013-02-02 05:58:35

5. Very helpful!!
View Tutorial          By: mahesh at 2012-07-12 06:24:50

6. Hello, I have stupid questions, but I need to ask
View Tutorial          By: Johnson Edison at 2012-12-13 17:10:57

7. Hi Friends.... This code is working correctly with
View Tutorial          By: kasi at 2009-11-25 23:52:56

8. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial          By: amit doshi at 2009-04-06 02:00:28

9. very good example and explanation. This kind of p
View Tutorial          By: jagdish at 2011-07-03 15:15:02

10. Hi : Pulkit Malviya .I think that book has coding
View Tutorial          By: Anand at 2012-11-04 14:13:50