A nested list holds integers and, recursively, further nested lists: [[1, 1], 2, [1, 1]]. Write an iterator that returns the integers in order, one at a time.
new NestedIterator(nestedList)hasNext() - true if another integer remains. It must be correct for lists such as [[], [[]]], and calling it twice in a row must change nothingnext() - the next integer. Throw an Error when there is none- Be lazy: the constructor must not read the items, and the memory should be proportional to the nesting depth, not to the number of integers