-1
import java.util.Stack;
public class PalindromeTest {
public static void main(String[] args) {
String input = "test";
Stack<Character> stack = new Stack<Character>();
for (int i = 0; i < input.length(); i++) {
stack.push(input.charAt(i));
}
String reverseInput = "";
while (!stack.isEmpty()) {
reverseInput += stack.pop();
}
if (input.equals(reverseInput))
System.out.println("Yo! that is a palindrome.");
else
System.out.println("No! that isn't a palindrome.");
}
}
在上面的程序中是什么目的: reverseInput + = stack.pop();
当你分配时发生了什么,这个.i与这条线混淆,可以任何一个解释?想知道使用