Reputation: 47
In my project, I'm working with webservices. To play with them, I use an Hastable in java. I m working with 1.6.x java version. I have an Hashtable declared as
Hashtable<String, String> props1 = new Hashtable<String, String>();
I could put data in like this
props1.put("@aze", values);
The 9 first element: no problem, all work well. At the 10 one, it a crash... and i don't understand.
How could I do ?
many thx
edit: full code source
public static void main(String[] args) {
Hashtable<String, String> props1 = new Hashtable<String, String>();
props1.put("@matricule", values[0]);
props1.put("@nom", values[1]);
props1.put("@prenom", values[2]);
props1.put("@email", values[3]);
props1.put("@estoccasionnel", values[4]);
props1.put("@adresse", values[5]);
props1.put("@codepostal", values[6]);
props1.put("@ville", values[7]);
props1.put("@telfixe", values[8]);
props1.put("@telmobile", values[9]);
}
code break at props1.put("@telmobile", values[9]);
with error message
java.lang.ArrayIndexOutOfBoundsException: 9
at CommandLineCreationWebservice.main(CommandLineCreationWebservice.java:99)
Upvotes: 0
Views: 127
Reputation: 2112
props1.put("@telmobile", values[9]);
the values array doesn't have a 10th value. That's the meaning of java.lang.ArrayIndexOutOfBoundsException: 9
(zero-based index in java)
Upvotes: 3
Reputation: 2158
The problem is in your values array not in hashtable. Probably your size of values array is not enough. It should be at least 10 in this case.
Upvotes: 0
Reputation: 8695
Java Hashtable is capable of storing a large amount of object (depending on your heap size). In any case it is way more, that 10.
Upvotes: 2