Hamlet is named before he comes on stage; he is named after he is dead. When is he first named and last named?
Hamlet, Prince of Denmark (not to be confused with his deceased father, Hamlet, King of Denmark) is first mentioned by name at the end of Act 1, sc. 1, approximately line 176. Horatio, having been summoned by Marcellus to witness the walking of the ghost of the dead King Hamlet, and having seen the ghost for himself, says that they need to go to young Hamlet and let him know what they have seen. Hamlet is last named in the play at the end of Act 5, scene 2, when Fortinbras says his name. Hamlet has been killed in the sword fighting scene because Laertes scratched him with the poisoned tip of his (Laertes) sword. Fortinbras, who, throughout the play, has been gathering forces and preparing to attempt to retake the lands his father lost to King Hamlet, has invaded Denmark. Before he died, young Hamlet told Horatio that Fortinbras has his blessing to take the throne of Denmark, which Fortinbras does. Fortinbras then commands four captains to take up Hamlet's body and give him the kind of honorable and respectful funeral that might be given to a king.