简体   繁体   English

哈希表长度限制Java

[英]Hashtable length limit java

In my project, I'm working with webservices. 在我的项目中,我正在使用Web服务。 To play with them, I use an Hastable in java. 为了和他们一起玩,我在Java中使用了Hastable。 I m working with 1.6.x java version. 我正在使用1.6.x Java版本。 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]); 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. values数组没有第十个值。 That's the meaning of java.lang.ArrayIndexOutOfBoundsException: 9 (zero-based index in java) 这就是java.lang.ArrayIndexOutOfBoundsException: 9的含义java.lang.ArrayIndexOutOfBoundsException: 9 (java中从零开始的索引)

Java Hashtable is capable of storing a large amount of object (depending on your heap size). Java Hashtable能够存储大量对象(取决于您的堆大小)。 In any case it is way more, that 10. 不管怎么说,更多的是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. 在这种情况下,至少应为10。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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