Java单链表的代码实现(2)

StringBuilder sb = new StringBuilder("[");
            for (Node current = header; current != null; current = current.next) {
                sb.append(current.data.toString() + ", ");
            }
            int len = sb.length();
            return sb.delete(len - 2, len).append("]").toString();
           
        }
    }
}

测试类:

package com.ietree.basic.datastructure.linklist;

public class LinkListTest {
    public static void main(String[] args) {

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6a09e8eb1c48fc57cd6f357531d980d4.html