判断一个数字是否为回文数(java实现)

/**
 * @author fanaz
 * @create 2020-07-28-15:12
 */
public class IsHWDigital {
    public static void main(String[] args) {
        isHWDigital(1232111);
    }
    
    public static void isHWDigital(int num ){
        boolean flag;
        String str = String.valueOf(num);
        StringBuilder sb = new StringBuilder(str);
        if(str.equals(sb.reverse().toString())){
            flag=true;
            System.out.println(flag);
        }else{
            flag=false;
            System.out.println(flag);
        }
    }
}

 

你可能感兴趣的:(面试)