Taiwan's supreme court on Friday upheld the death sentence given to a university student over a random May 2014 knife attack in a subway car in the capital Taipei that left four people dead and 22 injured.

The denial of Cheng Chieh's third and final appeal draws a line under one of the most shocking crimes to strike the island's prosperous and generally non-violent society in years.

Before the attack, Cheng posted a message on his Facebook page saying he "wanted to do something big." During sentencing by a lower court, he was quoted as saying that he would not mind receiving a death sentence.

Memories of the case were revived last month with an apparently random knife attack and decapitation of a three-year-old girl in front of her mother in Taipei. A 33-year-old man with a history of drug use and mental illness has been arrested in that case.

Some social scientists have questioned whether social alienation, joblessness and a loss of hope in the future were fueling such actions among young men.

Despite a legal push to abolish the death penalty, it continues to receive strong support among the public. Executions are carried out by a single gunshot to the head.