0
我的工作代码:把一份声明中一次循环之前
公共类SimpleStackDemo {
public static void main(String[] args) {
SimpleStack sT1 = new SimpleStack(10);
char ch;
System.out.println("Outputs:" + "\rDemonstrate SimpleStack" + "\n");
System.out.println("Push 10 items onto a 10-element stack." + "\rPushing: ");
for(ch = 'A'; ch < 'K'; ch++) {
sT1.push(ch);
System.out.print(ch);
给了我这样的输出:
Outputs:
Demonstrate SimpleStack
Push 10 items onto a 10-element stack.
Pushing:
ABCDEFGHIJ
但我想它给我这个输出:
Outputs:
Demonstrate SimpleStack
Push 10 items onto a 10-element stack.
Pushing: ABCDEFGHIJ
我可以'弄清楚如何让A-J在推动前面朝上:。我试过\b
,我试过把它放在循环中,然后在循环之前,我会得到Pushing: A
Pushing: B
等等或其他迭代,在这种迭代中抛出多次。
这是一个简单的事情,我没有看到哪些不需要我做一个全新的编码块?
假设您在一个单独的行中使用'System.out.print(“Pushing:”);''。 –