The Artima Developer Community
Sponsored Link

Java Answers Forum
can some teach me how to do palindrome this is wat i have

1 reply on 1 page. Most recent reply: Oct 9, 2002 3:05 AM by Sridhar

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Cshah

Posts: 16
Nickname: tkc204
Registered: Oct, 2002

can some teach me how to do palindrome this is wat i have Posted: Oct 8, 2002 5:28 PM
Reply to this message Reply
Advertisement
this is wat i have i dont know wat im doing wrong i get an error


public static void palinDrome(String word)
{
String b;
word = word.toLowerCase();
for ( int x = 1; x < word.length(); x++)
{
b = word.substring(x, x -1);


}


Sridhar

Posts: 3
Nickname: sweetsri
Registered: Oct, 2002

Re: can some teach me how to do palindrome this is wat i have Posted: Oct 9, 2002 3:05 AM
Reply to this message Reply
Hey the total program is here....

public class Palin
{
public boolean isPalin(String word)
{
boolean flag = true;
for(int i=0,j=word.length()-1;i<word.length()/2 && flag;i++,j--)
{
if (word.charAt(i)!=word.charAt(j))
{
flag = false;
}
}
return flag;
}
public static void main(String[] args)
{
Palin p = new Palin();
if (p.isPalin("Raj"))
System.out.println("It is Palindrome...");

else
System.out.println("It is not Palindrome...");
}
}

Flat View: This topic has 1 reply on 1 page
Topic: java vectors question Previous Topic   Next Topic Topic: Capturing mouse events generated on form field elements in JTextPane


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us