Handle collection in Java