2017-09-17 35 views
-1

我試圖在整型驅動程序類中調用此方法,但它不起作用。請誰能幫助我如何在驅動程序類中調用泛型方法

public SLL<T> missing(SLL<T> testList) 
{ 
    if(this.head == null) 
    { 
     return testList; 
    } 
    if(testList.head == null) 
    { 
     return null; 
    } 
    SLL<T> returnList = new SLL<T>(); 
    Element<T> ptr = testList.head; 

    while(ptr!= null) 
    { 
     if(!isMember(ptr.data)) 
     { 
      returnList.append(ptr.data); 
      return returnList; 
     } 
     ptr = ptr.next; 
    } 
    return returnList; 
} 
+1

你是怎麼稱呼它的?什麼不工作?在驅動程序類中調用方法 – algrid

+0

。我不知道如何調用它,我在驅動類中創建了一個對象,我需要給它檢查一個整數 – Armee

+0

@Armee提示:如果你沒有發佈它,我們就看不到你的代碼。發佈你的嘗試。發佈您獲得的確切完整的錯誤消息。 –

回答

0

在while循環只是刪除return returnList;。如果滿足if條件,則while循環在該點退出。

+0

我如何在整數參數的驅動程序中調用它? – Armee

+0

此方法可能在「SLL」類中。你可以使用'SLL sll = new SLL <>();'並且調用'sll.missing();' – Cedric

+0

它可以創建一個新實例,謝謝 – Armee

相關問題