Revenge is short-lived, justice is forever.
This realization does not happen until Hamlet has blown off steam and examined both his own conscience and the ramifications of swift revenge. Finally, it hits him: "Why, what an ass am I! This is most brave,/That I, the son of a dear father murdered,/Prompted my revenge by heaven and hell,/Must like a whore, unpack my heart with words...".
Through these lines of "self-talk" Hamlet realizes that merely revenge will be served if he acts in haste. Much better than revenge is justice. By the conclusion of the soliloquy, Hamlet has formed his plan of entrapment. "The plays the thing" he decides, that will ferret out the reluctant conscience of the evil Claudius. And justice is sweeter than any rash revenge could ever be.
Actually it is a revenge tragedy.Hamlet wants to take revenge of his father who is killed by his uncle Claudius with deception.He is too informed by the Ghost and he wishes to kill him but he lates and circumstance turns against him.He first of all avoids taking the hasty steps,for that he stages play and appreciates the role of the actor.On it he condemns himself and prefers the actor.Then he realizes that the actor is slave to the writer,but he is not.He wants to take revenge but avoids killing him in prayer,because he will enter in heavendirectly. And on the other place,he avoids killing him because his mother is with him.Whenever,he misses chance ,he condemns himself and enquires of flial love.