patterns using java