Time And Space Complexity In Java