Java reusable code