You can find the answer in the First Act Scene I. In a nutshell, the watchmen see a figure similar to the one of a ghost. They claim it is the dead king of Denmark judging by his appearance and way of walking. They especifically describe his uniform and the sword he used. They mention all this in their conversation with Prince Hamlet