All pastes #72788 Raw Edit

Miscellany

public java v1 · immutable
#72788 ·published 2006-06-27 04:06 UTC
rendered paste body
public class Palindrome {        public int palindrome(int x) {                boolean neg = x<0;                x = (int)Math.abs(x);                int[] x2 = new int[Integer.toString(x).length()];                for(int i=0; i<x2.length && x>10; i++) {                        x2[i] = x%10;                        x2[i] /= 10;                }                return neg?-x:x;        }        public int newPalindrome(int x) {                boolean neg = x<0;                x = Integer.parseInt(new StringBuffer(Integer.toString((int)Math.abs(x))).reverse().toString());                return neg?-x:x;        }}