How can i compare two input values to two arrays
This question already has an answer here:
So, based on what I can see, there is a direct correlation between the userNameArray
and passwordArray
, meaning that the value at n
in the userNameArray
corresponds to the value at n
in the passwordArray
This means your entire search can be boiled down to a single if
statement...
for (int index = 0; index < userNameArray.length; index++) {
if (str1.equals(userNameArray[index]) && str2.equals(passwordArray[index])) {
return true;
}
}
return false
Now, having said, it would be SO much simpler if you have some kind of plain old Java object (POJO) which encapsulated the username and password it could then provide validation functionality
链接地址: http://www.djcxy.com/p/92182.html上一篇: HashMap与TreeMap的Firebase性能
下一篇: 我怎样才能比较两个输入值到两个数组