"Something is rotten in the state of Denmark," says Marcellus in Shakespeare's "Hamlet," employing the metonymy of "state of Denmark" for the royal household. Metonymy substitutes a word or name for another thing affiliated with that word, as when you use "the White House" to refer to the presidential administration. Metonymy, like the metaphors from which it springs, abounds in the Prince of Denmark's tragedy.
Parts and Wholes
Both the ghost and Claudius refer to their "crowns" when they speak of the kingdoms they have lost and won. "Give every man thy ear," says the busybody Polonius, exhorting his son Laertes to listen to all. When Hamlet kills Polonius, he intends to "lug the guts" elsewhere, referring to moving the corpse.
To Be, Metonymy
"By a sleep to say we end the heart-ache" is perhaps the most famed metonymy in "Hamlet," as it connects sleep to death, an emblematic connection that infuses Act Three's "To be, or not to be" monologue. Even that antithetical beginning takes the word "be" and makes it a metonymous cousin to "exist" and "live."