Segment Tree in Java