Speaking at the end of a week-long trip to New Zealand, Harry said the armed forces had done amazing things for him.
Harry even suggested a future in the forces for his nephew and niece Prince George and Princess Charlotte.
The prince is set to spend the summer working alongside conservation groups in Africa, having ended his Army days.
Speaking about a career in the military, he said: "Without a doubt, it does keep you out of trouble. Different people do it for different reasons.
"I did it because since I was a kid I enjoyed wearing the combats, I enjoyed running around with a rifle, jumping in a ditch and living in the rain, and stuff.
"But then when I grew up, it became more than that, it became an opportunity for me to escape the limelight.
"I've had an epic 10 years, I've had great fun. The Army keep giving me great jobs, and I can never thank them enough for that."
Prince Harry also reiterated his support for the return of National Service.
"I dread to think where I'd be without the Army. Bring back National Service - I've said that before," he said.
"But I put my hand up, as I said to the kids today, you can make bad choices, some severe, some not so severe.
"You can make bad choices in life, but it's how you recover from those and which path you end up taking.
"And the Army has done amazing things for me. And more importantly to me, what I've seen the Army do to other young guys."
On the final day of his eight-day tour of New Zealand, Harry scored the winning goal in the dying seconds of a football match to the delight of a cheering crowd.
The prince took part in the five-a-side game with a group of young players to promote the Fifa Under-20 World Cup which starts in New Zealand later this month.
Prince Harry has said joining the Army definitely kept him out of trouble, adding that he dreaded to think where he would be now had he not done so.