All pastes #38197 Raw Edit

Someone

public java v1 · immutable
#38197 ·published 2006-01-23 17:13 UTC
rendered paste body
import java.io.*;import java.util.Stack;class Palindroom{	public static String readLine()	{		try		{			InputStreamReader i = new InputStreamReader(System.in);			BufferedReader j = new BufferedReader(i);			return j.readLine();		} catch (Exception e) {			return null;		}	}	public static boolean checkPalindroom(String str)	{		Stack s = new Stack();		for (int i = 0; i != str.length(); ++i)		{			char c = str.charAt(i);			if (Character.isDigit(c) || Character.isLetter(c))			{				s.push(new Character(str.charAt(i)));			}		}		String left = "";		while (!s.empty())		{			left += s.pop();		}		if (left.equals(reverse(left)))			return true;		return false;	}	public static String reverse(String s)	{		StringBuilder sb = new StringBuilder(s);		return sb.reverse().toString();	}	public static void main(String[] args)	{		for (;;)		{			String input = readLine();			if (input.equals("stop"))				return;			if (checkPalindroom(input))				System.out.println("Dit is een palindroom");		}	}}