2016-04-08 45 views
-1
public void sort(){ 

Node sortedList = null; 

    while(sortedList != null){ 

    Node current = sortedList; 
    sortedList = sortedList.next; 
    Node x; 
    Node previous = null; 
    for(x = sortedList; x != null; x = x.next){ 
     if(current.value < x.value){ 
       break; 
     } 
     previous = x; 
    } 
    if(previous == null){    
      current.next = sortedList; 
      sortedList = current; 
    } 
    else{    
     current.next = previous.next; 
     previous.next = current; 
    } 

    return sortedList; 
}}} 

這是錯誤消息:如何在Java中解決「錯誤:找不到符號」?

LinkedList.java:352: error: cannot find symbol 
if(current.value < x.value){ 
     ^
symbol: variable value 
location: variable current of type `LinkedList.Node` 
+0

這是錯誤消息LinkedList.java:352:錯誤:找不到符號 如果(current.value user6157611

+1

它的可變電流似乎沒有變量,名稱值在類中可訪問節點 – Stultuske

+0

告訴我們「節點」的定義 –

回答

1

這是因爲方法sort()的返回類型是void,但你嘗試從sort()

return sortedList; 

返回值看你的代碼,我想您可能希望將其聲明爲:

public Node sort() 

附加說明:您發佈的代碼片段似乎有額外的大括號}。您可能也需要查找。