completely new to Java, I am trying to find the matched element from one array into another, cannot seem to understand how to do it. Here is a sample of how the data is and how far I've gotten:
In this code and after printing this line, this is how the data is:
ArrayList<String> all_accounts = new ArrayList<String>(); all_accounts.add(acc); System.out.println("\nArray 1:" + all_accounts); Result Array 1:
Array 1:[77737320] Array 1:[88405378] Array 1:[00056893] Array 1:[10709816] ArrayList<String> cancel_accounts = new ArrayList<String>(); cancel_accounts.add(cancel_acc); System.out.println("\nArray 2:" + cancel_accounts); Results from Array 2:
Array 2:[77737320] Array 2:[] Array 2:[] Array 2:[] Stack here, I still cant understand why it doesn't match:
String found = null; for (String account: all_accounts) { for (String canceled: cancel_accounts) { System.out.println(canceled); found = canceled; } System.out.println(found); if(account.equals(found) ) { System.out.println(account); } } I need to find the matched element, 77737320 in this case. Thanks for looking!