Code snippets for Java and Scala