Improve java snippets