Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用用户输入搜索链表-Java_Java_Data Structures_Linked List_User Input - Fatal编程技术网

使用用户输入搜索链表-Java

使用用户输入搜索链表-Java,java,data-structures,linked-list,user-input,Java,Data Structures,Linked List,User Input,我已经创建了我的链接列表,我希望用户输入一个电台,然后输出为该电台存储的号码 LinkedList myList = new LinkedList(); myList.addFirst("London", 5); myList.addNode("Manchester ", 10); myList.addNode("Liverpool", 20); myList .addNode("Birmingh

我已经创建了我的链接列表,我希望用户输入一个电台,然后输出为该电台存储的号码

    LinkedList myList = new LinkedList();



            myList.addFirst("London", 5);            
      myList.addNode("Manchester ", 10);

      myList.addNode("Liverpool", 20);
      myList .addNode("Birmingham", 50);
这是供用户输入的输入

          String name;              
              name = JOptionPane.showInputDialog("Enter Station: ");


   StringNode  temp;

       temp = mylist.head;

       if (temp.Station == (name)) {


           System.out.println("Yes");


       }
其余的方法只是添加新的数据和打印


谢谢

这个问题就是HashMap的作用所在

Map<String, Integer> map = new HashMap<>();
map.put("London", 5);            
map.put("Manchester ", 10);
map.put("Liverpool", 20);
map.put("Birmingham", 50);

String station = "Liverpool";
Integer i = map.get(station);
System.out.println(i);
Map Map=newhashmap();
地图.put(“伦敦”,第5页);
地图放置(“曼彻斯特”,第10页);
普特地图(“利物浦”,20);
地图放置(“伯明翰”,50);
字符串station=“利物浦”;
整数i=map.get(station);
系统输出打印LN(i);

我试过了,但对于不起作用的链表,请再试一次。temp.Station==(名称)应为temp.Station.equals(名称)。假设空间站是一根弦。