I have an ArrayList like below
ArrayList<String> fList = new ArrayList<>();
fList.add("100510-0001");
fList.add("100510-0001");
fList.add("100513-0004");
fList.add("100510-0002");
fList.add("100510-0001");
fList.add("100513-0005");
fList.add("100513-0006");
fList.add("100518-0006");
fList.add("100599-0001");
fList.add("100593-0009");
I need to send an email based on first 6 characters of the List values.
Example: I have 100510 repeated 4 times in the list so I need to send all 4 records in the same email, like below hardcode one.
I have 100513 3 times, I can have n number of lists but I need to do recursion/iteration and send the email with the same records i.e 100510 in a separate email and 100513 in a separate email etc...
Any help?
ArrayList<String> subList = new ArrayList<>();
for (int i = 0; i < fList.size(); i++) {
String subString = fList.get(0).split("-")[0];
if(fList.get(i) == "100510"){
subList.add(fList.get(i));
createEmail(subList);
}
if(fList.get(i) == "100513"){
subList.add(fList.get(i));
createEmail(subList);
}
}