我不知道我是否理解你的問題。這是你的問題。 你要創建鏈表的陣列中的程序有名字的「字符串數組」,
:您在節點具有字符串名稱,如果你添加正確的話,你會得到LinkedList的。
但是有些名稱在數組的「相同位置」。例如,如果名稱morgan在數組[0]中,並且john也在數組[0]中,那麼我如何創建一個鏈接列表來允許兩個名稱存儲在同一個索引中。
:如何在對象中添加一個Sting,它是你想要的?
class Node{
String firstName;
String secondName;
Node next = null;
}
不知道我是否正確啓動,但是這是我迄今爲止
:你應該用一個構造函數首先啓動並進行添加,刪除等功能。
public Class CustomList{
private CustomList head;
private int index = 0;
private Class Node{
private String firstName;
private String secondName;
private Node next;
**constructor**
public Node(String firstName, String secondName){
this.firstName = firstName;
this.secondName = secondName;
next = null;
}
}
**constructor**
public CustomList(){
head = null;
}
}
上面將包含在CustomList的相同的索引兩個字符串值。 如果我理解錯誤的問題或者有任何問題可以隨意問。
嗯,你有一個'LinkedList'類。什麼阻止你創建一個'LinkedList'數組? –
你的問題不清楚! – lihongxu
詳細說明,我需要清楚些什麼? –