Add two java snippets and slightly modify other two