Hi i'm new here in daniweb i would like to ask about my program
i'll make a program that show if the word is palindrome or not can you correct my program when i complie my program its say Process complete then when i run the program it doesn't show the output can you help me pls!

import javax.swing.*;

public class Palindrome
{
    public static void main(String[] args) 
    {
        String A;
        int i,palindrome=1;
        A=JOptionPane.showInputDialog(null,"Enter a Word");
        
        for(i=0;i<A.length()/2;++i)
        {
        	if(A.charAt(i)!=A.charAt(A.length())-i-1)
        	{
        		palindrome=0;break;
        	}
        	if(palindrome==1)
        	System.out.println("The Word "+A+" is a Palindrome"); 
        	else
        	System.out.println("The Word "+A+" is not a Palindrome");
        }
    }
}

Hi i'm new here in daniweb i would like to ask about my program
i'll make a program that show if the word is palindrome or not can you correct my program when i complie my program its say Process complete then when i run the program it doesn't show the output can you help me pls!

import javax.swing.*;

public class Palindrome
{
    public static void main(String[] args) 
    {
        String A;
        int i,palindrome=1;
        A=JOptionPane.showInputDialog(null,"Enter a Word");
        
        for(i=0;i<A.length()/2;++i)
        {
        	if(A.charAt(i)!=A.charAt(A.length())-i-1)
        	{
        		palindrome=0;break;
        	}
        	if(palindrome==1)
        	System.out.println("The Word "+A+" is a Palindrome"); 
        	else
        	System.out.println("The Word "+A+" is not a Palindrome");
        }
    }
}

I don't believe your if statement should be inside of your loop, right?

Move the if statement down below the closing brace that comes directly after it.

I don't think just giving you the code would help you much, but try google'ing java's "reverse" function.

It should give you everything you need, and help you rewrite the code you have in much less lines as well. Enjoy!

String reversing

More reversing

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.