Java performance practice