嗨,我的代码中有此警告。我尝试使用
进行编译@SuppressWarnings(“未选中”)
它可以编译,但是在执行时程序找不到主类。
如何解决此问题?
下面的代码:
import java.util.*;
@SuppressWarnings("unchecked")
class ProgRub {
public static void main(String argv[]) {
Hashtable rubrica = new Hashtable(20);
String chiave, valore;
Menu mioMenu = new Menu();
int scelta;
scelta = (int) mioMenu.scelta();
while (scelta != 5) {
if (scelta == 1) {
chiave = mioMenu.leggiDato("Nome:");
valoe = mioMenu.leggiDato("Valore:");
rubrica.put(chiave, valore);
} else if (scelta == 2) {
chiave = mioMenu.leggiDato("Nome:");
rubrica.remove(chiave);
} else if (scelta == 3) {
Iterator i = rubrica.keySet().iterator();
while (i.hasNext()) {
chiave = (String) i.next();
valore = (String) rubrica.get(chiave);
System.out.println(chiave + "tel." + valore);
}
}
else if (scelta == 4) {
chiave = mioMenu.leggiDato("Nome:");
if (rubrica.contains(chiave)) {
valore = (String) rubrica.get(chiave);
System.out.println("Telefono:" + valore);
}
else {
System.out.println("Nominativo inesistente.");
}
}
scelta = (int) mioMenu.scelta();
}
System.out.println("Fine programma.");
}
}
答案 0 :(得分:0)
您将Hashtable
和Iterator
用作原始类型。如果您将它们分别用作Hashtable<String, String>
和Iterator<String>
:
要了解更多信息,建议您花些时间阅读Java泛型: