Я использую BlueJ в качестве своей IDE. По какой-то странной причине я получаю сообщение об ошибке в этой строке кода:
import javax.swing.*;
public class RotateArrayCircularLL
{
private Node head=null;
// ==================================================================================
public void init()
{
int choice = 0;
while (choice != -1){
choice = Integer.parseInt(JOptionPane.showInputDialog("Enter -1 to stop loop, 1 to continue"));
if(choice == -1)
break;
inputNum();
}
printList();
}
public void inputNum()
{
Node n;
Node temp;
int k;
k = Integer.parseInt(JOptionPane.showInputDialog(null,"Enter a number:"));
n = new Node(k);
if (head == null) {
head = n;
} else {
temp = head;
while (temp.getNext() != null)
temp = temp.getNext();
temp.setNext(n);
}
}
public void printList()
{
Node temp = head;
Node d, e;
int count = Integer.parseInt(JOptionPane.showInputDialog("Enter the value to shift to the right"));
for (int i = 1; i <= count; i++) // Rotates the head
temp = temp.getNext();
for (e = head; e != null; e = e.getNext()){
if (e.getNext() != null)
System.out.print(e.getInfo() + "-");
if (e.getNext() == null)
System.out.print(e.getInfo());
}
for (Node c = temp; c != null && c.getNext() != head; c= c.getNext()){
System.out.print(c.getInfo() + "-");
}
for (d = head; d != null && d.getNext() != temp; d = d.getNext())
{
System.out.print(d.getInfo()+ "-");
}
System.out.println(d.getInfo());
}
}
Ошибка: не удается найти символ-метод getNext ().
Раньше код работал отлично, но недавно мой компилятор завис и не отвечал, поэтому я завершил процесс через диспетчер задач. С тех пор он начал действовать.
Может кто-нибудь объяснить, почему он не работает? Я не думаю, что это моя проблема, а скорее компиляторы.