-1
IDEとしてBlueJを実行しています。いくつかの奇妙な理由で、私はこのコード行でエラーが発生します。シンボルメソッドgetNext()が見つかりません?
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をを見つけることができません。
コードは完全に動作していましたが、最近私のコンパイラはフリーズして応答しませんでしたので、タスクマネージャでプロセスを終了しました。それ以来、それは行動し始めた。
誰もがなぜ機能しないのか説明できますか?私はそれが私の問題ではなく、むしろコンパイラだと思います。
もう少し文脈が役立ちます - どのオブジェクトタイプが 'temp'ですか?その方法は何ですか?結果的にその署名は何ですか? – Makoto
'temp'のタイプ(クラス)は何ですか?それはあなた自身のクラス、またはいくつかのシステムクラスの1つですか?あなたはそれが 'getNext()'メソッドを持っていると確信していますか? –
一時は何ですか? whileループの前に来るコードを投稿してください。 – kosa