import java.util.Scanner; import java.io.*; class Node { String s; Node next; Node(String str) { this.s = str; } Node() { } } // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); Node dummy = new Node(); while (scanner.hasNext()) { String s = scanner.next(); Node t = new Node(s); t.next = dummy.next; dummy.next = t; } Node cursor = dummy.next; while (cursor != null) { System.out.print(cursor.s + " "); cursor = cursor.next; } System.out.println(); } }