问题描述
我遇到了问题请尝试解决。在我的项目中,我需要arraylist,其大小可能相同或不同。我想添加两个arraylist的元素,即arr1 [0] + arr2 [0],arr1 [1] + arr2 [1]。
我的问题是如果两个arraylist的大小不同那么如何添加超出索引的元素,即如果arr1有三个元素,arr2有四个元素,那么arr1和arr2的第三个元素它工作正常但是在arr1的第四个索引不存在则显示错误....
谢谢
Hi,
I am stuck with a problem pls try to solve. In my project i have to arraylist whose size may or may be not same. I want to add elements of the two arraylist i.e arr1[0]+arr2[0],arr1[1]+arr2[1].
My problem is if the size of two arraylist is different then how it add the elements which is out of index i.e if arr1 has three elements and arr2 has four elements then upto third element of arr1 and arr2 it works fine but at the fourth index of arr1 which does not exist is shows error....
thanks
推荐答案
这篇关于如何添加两个动态arraylist的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!