2016-04-08 67 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() 

附加说明:您发布的代码片段似乎有额外的大括号}。您可能也需要查找。