Input to my program is two list object. and the output that I am looking for is if the customer type in two list if same, prepare the output list which will contain common customername and customer type. I have written a test code to compare the two list, but it always prints the same message “not Contains”.
I am not sure what I am missing in the code. Please suggest.
FTCustomer ftcust = new FTCustomer(); ftcust.setName("CustomerA"); ftcust.setType("Emirates"); List<FTCustomer> customerFTList = new ArrayList<FTCustomer>(); customerFTList.add(ftcust); List<Customer> customerList = new ArrayList<Customer>(); Customer cust = new Customer(); cust.setCustomerName("CustomerA"); cust.setCustomerType("Emirates"); customerList.add(cust); cust = new Customer(); cust.setCustomerName("CustomerB"); cust.setCustomerType("Frontier"); customerList.add(cust); // for (int i = 0; i < customerList.size(); i++) { if (customerList.contains(customerFTList.get(0))) { System.out.println("Contains"); } else { System.out.println("Not Contains"); } //}
——– Logic to return my output…..