My question, which I posted, was closed with the given reason:
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist" – Thihara, halex, devnull, Michael0x2a, rcs
I had posted the code that I have tried and I had also mentioned the error that I got in Eclipse.
May I please know why the question was not taken up?