我写的查找链表中数据方法
现在我的链表数据为1,1,2,3,都是字符串类型的用方法找“1”,只找到一个,以后的都是null了。
程序代码:
public String[] finddate(String in) { datenode position = head; int count = 0; String[] result = new String[this.countdate()]; int n = 1; do { if (position != null) { while (position.date!=in) { position = position.next; } if (position.date==in) result[count] = "the location is " + (count+1); } else System.out.println("no date at all"); n++; count++; position = position.next; } while (n >= this.countdate()); return result; }