Q:

What data types to use when porting this recursive structure from Python to Java

In Python I have such a recursive structure:
[{a:b},({c:d}, {e:f}, [{g:h},{i:j}])]

In this recursive structure {} elements are atomic, in a sense, that when I parse this structure and come across {}, I just store it.  However, when I find [] or (), then I make another recursive step.  The difference between [] and () in my algorithm is that in the resulting string elements of [] are separated by OR and elements of () are separated by AND.  So, it looks like this:
[x, y, z] -> "( x OR y OR z )"
(x, y, z) -> "( x AND y AND z )"
[x, y, (z, w)] - > "( x OR y OR ( z AND w ) )"

In Python my algorithm works nice and produces correct strings, but I'm not even sure what data types to use in Java to do the same trick.  So, I need some advise.  Thanks! 

A:

Basically you are looking for an equivalent of Python's list in Java.  Python's list is heterogeneous and thus you might be stumped as List in Java is homogeneous. 
The first thing that you need to define is what to call the individual elements.  Let's call the common thing among all three by making a interface named MyStructure.  Then there are three implementing classes corresponding to the three types present

MyStructureElement - this should probably extend a Map as this is corresponding to {a:b} which is Python's dictionary
MyStructureTuple - this can probably extend a List<MyStructure>.  Choose whichever implementation you want
MyStructureList - same as above

Then the recursive structure needs to represented as 
MyStructureList myList = new MyStructureList()
myList.add(new MyStructureElement())

and so on add all elements. 
You would probably need to change the names.  That depends on your preference. 
Then when parsing you just have a check like
element instanceof MyStructureElement
element instanceof MyStructureTuple
element instanceof MyStructureList

That way you find what is the current element type

