Joyce makes a large number of allusions and intertextual references in Ulysses: two of most prominent in the novel are to Homer's Odyssey and Shakespeare's Hamlet. Joyce structures the novel and titles the chapters so that Bloom's journey through Dublin on a single day corresponds to Ulysses's voyages and heroic adventures, also rendering Stephen Dedalus a parallel to Telemachus and Molly Bloom a modern, if sexually unfaithful, Penelope. This appropriation at the same time both parodies modern life as a debased epic but also shows the way ordinary life is also filled with heroic, if usually uncelebrated, moments.
References to Stephen Dedalus as Hamlet are important because this appropriation is both allusive and intertextual. For example, Dedalus's home in Martello Tower is likened to Elsinore Castle, Hamlet's Danish home; Stephen's mother has died not long ago, just as Hamlet's father has (though Stephen's mother's death is a year old); and like Hamlet, Stephen wears black to mourn.
One aspect of intertextuality is to go beyond alluding to a text by having characters in the second work consciously use the original text to fashion a self-image or to comment on themselves or others. Dedalus does this with Hamlet. For example, he is not just wearing black so that Joyce can make a connection with Hamlet for the reader, but particularly chooses to wear black because he, Dedalus, self-consciously wants to identify with the character of Hamlet.
This intertextuality comes to the forefront in chapter 9 when Dedalus discusses his theory about Hamlet at the National Library, in which he uses his anger at his own father to promote the theory that Shakespeare identified with the dead King Hamlet and wanted to take revenge on his "son," Prince Hamlet. However, Dedalus needs to transcend his desire to forge an identity based on Hamlet just as the true writer/artist must learn to transcend reliance on previous literary sources in order to create something new.
It's worth noting that in these two main allusive and intertextual sources Joyce tried to use literary material that would be widely and easily understood by his audience.