gpt4 book ai didi

java - 线程中出现异常 "main"java.lang.IndexOutOfBoundsException

转载 作者:行者123 更新时间:2023-12-01 05:49:11 25 4
gpt4 key购买 nike

我正在传递这种类型的数组:-

Integer[] A={32,543,423};
Integer[] B={32,43};

方法:

public void method1(K[] Items1, N[] Items2, integerSerializerObject){  
method2(Items1, Items2); // this method again passes on the parameters to method2 & method3
}

传递到:-

public void method2(K... things1){  
}

public void method3(N... things2){
}

method2 和 method3 实际上属于一个名为 Hector 的库,用于访问 Cassandra DB,因此错误不存在,而是在我自己的代码中,仅在该方法之上。我将这两个数组与 IntegerSerializer 对象一起传递,以将这些数组元素转换为字节。完整的异常详细信息列表如下:(但是我觉得该错误位于我的代码中而不是库函数中,因此可能在我的代码中可见)

我收到此消息的异常:-

  Exception in thread "main" java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkIndex(Buffer.java:514)
at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:121)
at me.prettyprint.cassandra.serializers.IntegerSerializer.fromByteBuffer(IntegerSerializer.java:42)
at me.prettyprint.cassandra.serializers.IntegerSerializer.fromByteBuffer(IntegerSerializer. java:12)
at me.prettyprint.cassandra.serializers.AbstractSerializer.fromBytesMap(AbstractSerializer.java:115)
at me.prettyprint.cassandra.model.thrift.ThriftMultigetSliceQuery$1.doInKeyspace(ThriftMultigetSliceQuery.java:67)
at me.prettyprint.cassandra.model.thrift.ThriftMultigetSliceQuery$1.doInKeyspace(ThriftMultigetSliceQuery.java:59)
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:65)
at me.prettyprint.cassandra.model.thrift.ThriftMultigetSliceQuery.execute(ThriftMultigetSliceQuery.java:58)

你们知道我哪里做错了吗?

最佳答案

据我所知,Varargs 只能用于最后一个参数。正如该网站所述:

Varargs can be used only in the final argument position.

( http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html )

这会产生你的异常吗?

关于java - 线程中出现异常 "main"java.lang.IndexOutOfBoundsException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5132644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com