Add some java snippets; minor adjust to java style