Java code to perform operations on collections.