如何检查两个数组列表都在相同的位置相同的内容 [英] How to check two array list are same content in same position
问题描述
如何检查的价值和它的位置是在2数组列表无线一样吗?
例如:
//这些应该是不相等的。
ArrayList的<串GT; listA的= {一,B,C}
ArrayList的<串GT;数组listB = {B,C,一个}
在这个例子中的元素都没有在这两个数组列表相同的位置,以便返回false ..
如何检查在同一个位置值相同,而无需使用循环
我想如果预期这个结果。
//这应该是平等的。
ArrayList的<串GT; listA的= {一,B,C}
ArrayList的<串GT;数组listB = {一,B,C}
这种类型的数组列表,然后返回true,因为价值和位置都阵列中的相同。
使用
返回listA.equals(数组listB);
返回true当且仅当指定的对象也是一个列表,两个
列表具有相同的尺寸,并在元件的所有相应对
两个列表是相等的。
块引用>How to check value and its position are same in 2 array list wi?.
Example:
//These should be not equal. ArrayList<String> listA = {"a", "b", "c"} ArrayList<String> listB = {"b", "c", "a"}
In this example element are not same position in both array list so return false.. How to check same value in same position without using
for loop
I want to expected result this if.
//These should be equal. ArrayList<String> listA = {"a", "b", "c"} ArrayList<String> listB = {"a", "b", "c"}
this type array list then return true because the value and position are same in both array..
解决方案use
return listA.equals(listB);
Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal.
这篇关于如何检查两个数组列表都在相同的位置相同的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!