[英]Hashtable length limit java
在我的项目中,我正在使用Web服务。 为了和他们一起玩,我在Java中使用了Hastable。 我正在使用1.6.x Java版本。 我有一个哈希表声明为
Hashtable<String, String> props1 = new Hashtable<String, String>();
我可以这样放入数据
props1.put("@aze", values);
第九个要素:没问题,一切正常。 在十点,它崩溃了...我不明白。
我该怎么办?
许多
编辑:完整的代码源
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]);
}
props1.put(“ @ telmobile”,values [9])处的代码中断;
带有错误信息
java.lang.ArrayIndexOutOfBoundsException: 9
at CommandLineCreationWebservice.main(CommandLineCreationWebservice.java:99)
props1.put("@telmobile", values[9]);
values数组没有第十个值。 这就是java.lang.ArrayIndexOutOfBoundsException: 9
的含义java.lang.ArrayIndexOutOfBoundsException: 9
(java中从零开始的索引)
Java Hashtable能够存储大量对象(取决于您的堆大小)。 不管怎么说,更多的是10。
问题出在值数组中,而不是哈希表中。 值数组的大小可能不足。 在这种情况下,至少应为10。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.