The Coral Island: A Tale of the Pacific Ocean is a book written by R. M. Ballantyne and published in 1858. Golding was supposedly partially inspired to write Lord of the Flies because of his childhood experience with Ballantyne's book.
There are a lot of similarities between the two books. For example, both books have main characters named Jack and Ralph. The setting of both books is an island where the boys are stranded and forced to fend for themselves. Further, fire plays an important role in both books.
Despite these similarities, there are some key differences between the books. For example, Jack and Ralph successfully work together to build shelters and canoes in The Coral Island, while Jack and Ralph of Lord of the Flies do not cooperate successfully—in fact, Jack nearly orchestrates Ralph's murder in Golding's novel. The fire, while important in both novels, is used to very different effects. In Lord of the Flies, the fire is used by Jack as a weapon of destruction. The fire in The Coral Island is used to rid the island of "false gods" and ultimately to restore peace.
Golding doesn't try to hide his book's similarities. In fact, in two different locations, readers see that Golding specifically name-drops Ballantyne's book. The first time is in chapter 2: Ralph is explaining to the boys that they might be on the island for a long time, but it shouldn't be a problem. In his opinion, the island is a good island, and they can enjoy their time there while they wait for rescue.
“While we’re waiting we can have a good time on this island.”
He gesticulated widely.
“It’s like in a book.”
At once there was a clamor.
“Swallows and Amazons—”
Golding calls our attention to the other book at the end of the novel, and I think he does that to remind us that his novel is very different than the more idyllic Ballantyne book.
“We were together then—”
The officer nodded helpfully.
“I know. Jolly good show. Like the Coral Island.”