Various java code snippets