//栈的回文数据 public class Text02 { public static void main(String[] args) { System.out.println(text01("aba")); } //判断回文数据的方法 public static boolean text01(String val){ //初始化栈 ArrayStack as = new ArrayStack(10); //入栈 for (int i = 0; i <val.length() ; i++) { as.push(val.charAt(i)); } String newVal = "";//为了字符串拼接 int lenth = as.lenth();//防止pop方法在top--过程中引发的as.lenth()数据变化; //出栈 for (int i = 0; i < lenth; i++) { if(!as.isEmpty()){ char pop = (char) as.pop();//pop方法返回值拼接字符串; newVal = newVal + pop; } } if(newVal.equals(val)){ return true; } return false; } }
05-23
374

12-13
841

08-12
435

03-14
823
