THE BRONX, N.Y. (PIX11) — Robert Williams — convicted of opening fire on police officers in two separate incidents — defiantly walked into a Bronx courtroom Friday and got an earful from Brian Hanlon, one of the NYPD officers Williams tried to kill.

“I thought about this stuff every single day for two years. It brings me joy knowing your life is essentially over. I have no reason to believe that if you get out one day, that you won’t try to do it again. I hope, for everybody’s sake, you don’t live that long,” said Hanlon.

In February 2020, Williams approached a parked police van, began firing and shot Hanlon’s partner, Sgt. Paul Stroffolino, in the chin and neck. He miraculously survived and was in the courtroom Friday.

Hours later, Williams then brazenly walked into the 41st Precinct stationhouse and began firing, striking a lieutenant in the arm. He also survived.

Williams, 49, pleaded guilty of two counts of attempted murder in a negotiated plea deal. He was sentenced to 23 years to life in prison.

“Y’all beat me up and Tased me and swept it under the rug,” Williams said in court on Friday. “I made poor decisions, and I apologize to my family and to the cop. I didn’t try to kill nobody.”

But minutes later the Judge pointed out Williams has already made several incriminating statements — on the record — about his desire to kill cops and try it again after he’s released from prison.

“Your actions are inexcusable. I don’t know what the world is going to look like in 2043, but I know what that record is going to look like,” said Judge Ralph Fabrizio.

Police Benevolent Association President Pat Hendry said members of the NYPD’s largest union will never forget Williams’ actions.

“Unfortunately, in 23 years, this violent criminal will have another shot at freedom. Twenty-three years from now, we will be there to make sure this criminal stays behind bars where he belongs,” said Hendry.