......
flightsTable = new Hashtable();
flightsTable.put(flightNum, new Flights(flightNum, numSeats, price));
.......编译后 javac ResourceManagerImpl.java 产生如下信息: ^
Note: ResourceManagerImpl.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
再编译后 javac -Xlint ResourceManagerImpl.java 产生如下警告:
ResourceManagerImpl.java:91: warning: [unchecked] unchecked call to put(K,V) as
a member of the raw type java.util.Hashtable
flightsTable.put(flightNum, new Flights(flightNum, numSeats, pri
ce));请问如何解决??高手赐教。
flightsTable = new Hashtable();
flightsTable.put(flightNum, new Flights(flightNum, numSeats, price));
.......编译后 javac ResourceManagerImpl.java 产生如下信息: ^
Note: ResourceManagerImpl.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
再编译后 javac -Xlint ResourceManagerImpl.java 产生如下警告:
ResourceManagerImpl.java:91: warning: [unchecked] unchecked call to put(K,V) as
a member of the raw type java.util.Hashtable
flightsTable.put(flightNum, new Flights(flightNum, numSeats, pri
ce));请问如何解决??高手赐教。
它告诉你新建一个Hashtable 时应该指定 key 和 value 的类型,好让编译器帮你检查错误.Hashtable<String,Date> map = new Hashtable<String , Date>();以后你只能向里面 放 key 为 string , value 为 date 的东西, 别的就会出错.