Palindrome Örneği(Java-Substring)

Palindrome Örneği(Java-Substring) örneği için tıklayınız.


public class pandoFor {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String word="Laid on no dial";
		String reverse="";
		String notSpaces="";
		for(int i=0;i<word.length();i++)
		{
			String single=word.substring(i,i+1);
			if(single.equals(" "))
				continue;
			notSpaces=notSpaces+single;
				
		}
		
		for(int i=0;i<notSpaces.length();i++)
		{
			String single=notSpaces.substring(i,i+1);
			reverse=single+reverse;
		}
		
		if(notSpaces.equals(reverse))
			System.out.println(word+" is a palindrome");
		else
			System.out.println(word+" is not a palindrome");
	}

}
Palindrome

admin