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) {