Exception in thread "main" Java.lang.Error: Unresolved compilation issue:

Source: Internet
Author: User


public class Demo3 {

public static void Main (string[] args) {

Cyclink cyclink=new Cyclink ();
Cyclink.setlen (10);
Cyclink.createlink ();
Cyclink.show ();
CYCLINK.SETK (3);
Cyclink.setm (3);
Cyclink.play ();

}

}
Class Child
{
int no;
Child Nextchild=null;
public child (int no)
{
Give a number
This.no=no;
}




}
Ring Linked List
Class Cyclink
{
First define a reference to the first child in the list
A reference to the first child cannot move
Child Firstchild=null;
Child Temp=null;
It means there are a few children
int len=0;
int k=0;
int m=0;
Determining the step size of a number m
public void Setm (int m)
{
This.m=m;
}
Set the list size
public void Setlen (int len)
{
This. Len=len;
}
Set the number of people starting from the first few
public void setk (int k)
{
This.k=k;
}
Start play
public void Play ()
{
Child Temp=this.firstchild;
First, find the person who started counting.
for (int i=1;i<k;i++)
{
Temp=temp.nextchild;
}
while (this. Len!=1)
{
2. Several m under
for (int j=1;j<m;j++)
{
Temp=temp.nextchild;
}
Find the first child to be out of the loop
Child Temp2=temp;
while (temp2.nextchild! = temp)
{
Temp2=temp2.nextchild;
}
3. Pull the number of children out of the circle
Temp2.nextchild=temp.nextchild;
Let temp point to the next number of kids.
Temp=temp.nextchild;
This. len--;
}
The Last Child
System.out.println ("The last child out of the lap is:" +temp.no);
}
Initialize the ring list
public void Createlink ()
{
for (int i=1;i<=len;i++)
{
Create the first child
if (i==1)
{
Child ch=new Child (i);
This.firstchild=ch;
This.temp=ch;
}
Else
{
if (i! = Len)
{
Continue to create child
Child ch=new Child (i);
Temp.nextchild=ch;
Temp=ch;
Temp.nextchild=this.firstchild;
}
Else
{
Continue to create child
Child ch=new Child (i);
Temp.nextchild=ch;
Temp=ch;
}

}
}
}

Print the ring link
public void Show ()
{
Define a walk-in
Child Temp=this.firstchild;
Do
{
System.out.println (temp.no);
Temp=temp.nextchild;

}while (temp! = This.firstchild);
}
}

Exception in thread "main" Java.lang.Error: Unresolved compilation issue:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.