Java 访问LinkedList中的第二个元素有多个节点

Java 访问LinkedList中的第二个元素有多个节点,java,list,Java,List,我正在尝试访问linkedlist的患者id,以便使用查找方法仅访问该患者记录。因为每个患者都有自己的元素列表,所以我将每个列表彼此链接 到目前为止,数据是这样的,我是从一个文本文件中读取的-> 文本文件: Tim He 000001 1001 Square 66 130 03-03-2013 04-05-2014 04-06-2014 Mike rouch 000002 1001 Square 66 130 03-03-2013 04-05-2014 04-06-2014 Luis shin

我正在尝试访问linkedlist的患者id,以便使用查找方法仅访问该患者记录。因为每个患者都有自己的元素列表,所以我将每个列表彼此链接

到目前为止,数据是这样的,我是从一个文本文件中读取的-> 文本文件:

Tim He
000001
1001 Square
66
130
03-03-2013
04-05-2014
04-06-2014
Mike rouch
000002
1001 Square
66
130
03-03-2013
04-05-2014
04-06-2014
Luis shin
000003
1001 Square
66
130
03-03-2013
04-05-2014
04-06-2014
这是我添加到列表中时的输出

List:
  (Tim He, 000001)
  (Mike rouch, 000002)
  (Luis shin, 000003)
它只显示名称和id,因为这就是我的toString 如何访问id ex“000001”或“000002”以仅打印该患者数据

下面是我将患者数据添加到节点的方式

 protected int numElements;      // number of elements in this list
      protected LLNode<T> currentPos; // current position for iteration

      // set by find method
      protected boolean found;        // true if element found, else false
      protected LLNode<T> location;   // node containing element, if found
      protected LLNode<T> previous;   // node preceeding location

      protected LLNode<T> list;       // first node on the list

      public RefUnsortedList() {
        numElements = 0;
        list = null;
        currentPos = null;
      }

      public void add(T element)//Adds element to this list.
      {
     LLNode<T> prevLoc; //trailing reference
        LLNode<T> location; //traveling reference  

     location = list; //set up search for insertion point
     prevLoc = null;

     while (location != null) //find insertion point
         {  
      prevLoc = location;
      location = location.getLink();
      }

        LLNode<T> newNode = new LLNode<T>(element); 
     if (prevLoc == null) //insert node as 1st node
      {
      newNode.setLink(list);
      list = newNode; 
      }
      else
      { 
      newNode.setLink(location);
      prevLoc.setLink(newNode);
      }
      numElements++;
    }
受保护的整数;//此列表中的元素数
受保护的LLNode currentPos;//迭代的当前位置
//按find方法设置
找到受保护的布尔值;//如果找到元素,则为true,否则为false
受保护的LLNode位置;//包含元素的节点(如果找到)
受保护的LLNode-previous;//节点前进位置
受保护的LLNode列表;//列表上的第一个节点
公共拒绝列表(){
数值=0;
列表=空;
currentPos=null;
}
public void add(T元素)//将元素添加到此列表中。
{
LLNode prevLoc;//尾部引用
LLNode location;//移动引用
location=list;//设置插入点的搜索
prevLoc=null;
while(location!=null)//查找插入点
{  
prevLoc=位置;
location=location.getLink();
}
LLNode newNode=新的LLNode(元素);
if(prevLoc==null)//将节点作为第一个节点插入
{
setLink(列表);
列表=新节点;
}
其他的
{ 
newNode.setLink(位置);
prevLoc.setLink(新节点);
}
numElements++;
}

发布您的实施代码片段,以便我们了解您在做什么听起来您应该将患者放在从id到患者的
映射中,而不是放在
列表中。我只是不知道如何访问它例如:我可以打印出名单,但没有一张。我以前没有地图。