Foreshadowing is an indication of what is to come. An example of this is found in the Harry Potter book series. Severus Snape (or Professor Snape) asks Harry on his first day at Hogwarts this question “Potter, where would you look if I told you to find me a bezoar?" In book six of the series, Harry finds a note written by Professor Snape in an old potions book that mentions bezoars as a poison antidote. When Harry's friend, Ron, becomes poisoned, Harry is able to save him.
In The Hobbit, Bilbo, the dwarves, and Gandalf gained a treasure after defeating the trolls. They became greedy with the treasure and buried it and put spells on it so that no one else would take it.
This foreshadowed that the dwarves would become greedy when they took as much of the treasure that they could while the dragon was gone.