📅  最后修改于: 2022-03-11 14:52:10.184000             🧑  作者: Mango
public class Main{ Node head; static class Node { int data; Node next; Node(int d) {data = d;next=null; } } public void display() { Node n = head; while (n != null) { System.out.print(n.data+" \n"); n = n.next; } } public static void main(String[] args) { Main Main = new Main(); Main.head = new Node(10); Node second = new Node(15); Node third = new Node(20); Main.head.next = second; second.next = third; Main.display(); } }