I wanted to create an array of dynamic types as in javascript. I wanted to convert below code of javascript into java.
const a = [1, [2, 3, [4, 5,[6, 7]....]]]
The above array will have nested array for every 2 elements and depth can be infinite. It is dynamic.
Is there a way to create such array in java? As I found we need to declare before hand the nested arrays as below
List<List<Integer>>
But in above code, I can only use 2 nested list with integers that too I can't use combination of integers and List inside 1st list. If I want to add another list inside second list I need to declare as
List<List<List<Integer>>>
So I need a way to solve this problem