I have a class, called ADVAObject, with a variable "type" and "value":
public class ADVAObject {
String type = "";
String value = "";
}
Then, I did some ArrayList<ADVAObject> pattern = new ArrayList<ADVAObject>();.
After some processing, I ended up with this list using:
for(ADVAObject a : pattern) {
System.out.println(a.type + " : " + a.value);
}
The list:
STRING : V
STRING : A
STRING : R
STRING : I
STRING : A
STRING : B
STRING : L
STRING : E
SPACE : null
SPECIAL : null
SPACE : null
NUMBER : 3
NUMBER : 4
SPACE : null
DIV : null
SPACE : null
NUMBER : 5
NUMBER : 6
SPACE : null
QUESTION : null
As you can see, instead of getting "VARIABLE", I get it separated. This isn't a problem, for now. "For now"? Yes. You see, I wanted to keep them separated to do additional processing, but now I need to "merge", as said in the title of this question, all repeated elements which have a value (which aren't null). So:
//This:
STRING : AB
STRING : CD
STRING : EF
//Turns into this:
STRING : ABCDEF
//However, ...:
//This:
SPACE : null
SPACE : null
//Can't turn into this:
SPACE : null
//.
I have tried creating a seperate array and regexing it all inside some loops, but it didn't... work as expected.