Simulating functional operations to ArrayList