bonjour
mon prg ne compile pas
lors compilation il s'affiche le message suivante:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The local variable e may not have been initialized
at Hashtableexample1.main(Hashtableexample1.java:23)
veuillez m' aidez svp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import java.util.*; import java.util.Vector; public class Hashtableexample1 { public static void main(String[]args) { Hashtable<String,Integer>hash=new Hashtable<String,Integer>(4); String ob="ABC"; Integer in=new Integer(563); hash.put(ob,in); ob="XYZ"; in= new Integer(129); hash.put(ob,in); ob="MNO"; in=new Integer(6564); hash.put(ob,in); System.out.println("hash"); Vector<String>v=new Vector<String>(hash.keySet()); Collections.sort(v); for(Enumeration e=v.elements(); e.hasMoreElements();); { String key=(String)e.nextElement(); Integer val=(Integer)hash.get(key); System.out.println("Key:"+key+"Val:"+val); } } }
Partager