文章目录
第一步:必不可少的我们得事先准备有bug的程序,这里我准备了如下程序
class Boy
public class Boy {
//节点编号
private int no;
//指向下一个节点
private Boy next;
public Boy(int no) {
this.no = no;
}
public void setNo(int no) {
this.no = no;
}
public void setNext(Boy next) {
this.next = next;
}
public int getNo() {
return no;
}
public Boy getNext() {
return next;
}
}
class CircleSingleLinkedList
public class CircleSingleLinkedList {
private Boy first= new Boy(-1);
/**
* 构建环形链表
*/
public void addBoy(int nums){
if(nums<1){
<