I have a list of objects and i want to process subset of objects based on condition and then create a new list with processed objects.
The List if Objects
miss | shannon sperling
mr | john smith
prof | kim taylor
prof.dr | kim taylor
In the above list i want to the names which has two titles(kim taylor) and glue the title because prof is a subset of prof.dr. My final list should look like the following
miss | shannon sperling
mr | john smith
prof.dr | kim taylor
I tried with following code
void gluetitles(List title)
{
for (int i=0;i<title.size();i++) {
String names = (String) title.get(i);
String[] titlename=names.split("\\|");\\split the list with delimiter and extracts titles and names
String tle=titlename[0];
String name=titlename[1];
}
}
But i did not get idea how to compare and get the name which has two titles.
mr | kim taylorandprof | kim taylor