I actually do not have any plans to use any characters from another book in any of my books (either as fan fiction, a joke, or a reference). Out of interest, though, would it be legal to pull in a character from another series into my book as a joke (there is definitely no way to do this seriously)?
An example would be if I have some people walking around in 1800s London and they come across Sherlock Holmes. You could even take the idea farther and use the character as important character in your own story. Would that be legal?
EDIT: Okay, so I don't have a specific question here. I have a very broad question to the idea of using characters from other books. I never plan to do that, but was simply wondering about the legality of it. I am asking about generalities. There are exception (Sherlock Holmes being one of them), but I am merely interested in the general idea.