java pattern practise demo