简体   繁体   中英

Hashtable length limit java

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)
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)

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM