⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tryvehiclehashmapregistry-template.java

📁 This file contains all the vehicles program in one file.
💻 JAVA
字号:
import java.util.HashMap;
import java.io.*;

public class TryVehicleHashMapRegistry {
  public static void main(String[] args) 
    throws IOException
  {

   /***
    HashMap define 
   ***/

    Vehicle[] vhcs = {
      new Vehicle("Windom Toyota","Toyota","Corolla","1234A"),
      new Vehicle("Sunsuke Honda","Honda","Stream","14321B"),
      new Vehicle("Yusuke Toyota","Toyota","Avalon","1212A"),
      new Vehicle("Yuu Toyota","Toyota","Camry","3210B"),
      new Vehicle("Daisuke Honda","Honda","Accord","1111A"),
    };

    for (Vehicle v : vhcs) //*** Register the vehicles to HashMap registry

    BufferedReader charStream = new BufferedReader (new InputStreamReader(System.in)); 
    Vehicle v;

    while(true) {
      System.out.print("Enter the name you want: ");
      String data = charStream.readLine();   
      if(data.equals("")) break;
      v = registry.get(data);  //get the vehicle from the registry
      if(v != null) System.out.println("Answer:\n" + v);
      else System.out.println("No found");
    }

  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -