A highly sophisticated robot duplicate of Finnegan, a Starfleet Academy cadet, was created on the Shore Leave Planet. It was inspired by James T. Kirk's memories of the cadet while the crew of the USS Enterprise surveyed the planet in 2267.
"Finnegan" appeared exactly as he had when he and Kirk attended the Academy together in 2252. At that point, Kirk did not understand the nature of the planet, so he sought answers from "Finnegan", who was the first character that actually interacted with the landing party. These attempts earned Kirk only japes and mockery, and finally Kirk had enough – he chased down "Finnegan" and "beat the tar out of him" – something he'd been longing to do for years.
During their fight, he offered Kirk a valuable clue in his statements, "Kinda makes up for things, huh Jim?" and, "I'm being exactly the way you remember me." At the end of the fight, Kirk and Spock realized that "Finnegan", like all the other robots, had been created in response to the secret longings of the landing party members; in "Finnegan"'s case, Kirk's unvoiced desire for revenge against his former tormentor. (TOS: "Shore Leave")