While the Pentagon’s base budget was capped in 2011, funding for the military still far outstripped the rest of the world and was still higher than the next seven countries combined.

In the first months of his presidency, Mr. Trump visited the Navy’s newest aircraft carrier, the Gerald R. Ford, and promised to work to “upgrade” ships and submarines and seek more money for the sailors who operate them.

“We’ll have by far the most powerful nuclear force on earth, and it’ll be absolutely in perfect shape and condition,” Mr. Trump told the sailors on the ship that day. “And hopefully, praise be to God, we don’t ever have to use it. But there will be nobody that’s even close.”

In his remarks at the commencement on Friday, Mr. Trump took note of the carrier Ford as he touted the size and strength of the country’s naval forces, including what he said will eventually be “355 beautiful ships” in the fleet. He said that is “almost a couple of hundred more ships” than is currently in the fleet.

In fact, in 2016, the number of active ships was 275, and the Navy plans to increase that to 355 by the 2050s.

“We’re building that modern fleet,” he said. “We’re sharpening the fighting edge of everything.”

As president, Mr. Trump signed a $1.3 trillion government spending bill that drastically increased the amount of money for the military. At the signing, the president complained that he did not want to sign the legislation because it failed to close immigration loopholes or provide enough money for a wall along the southern border with Mexico.

But he said the money for the military was enough to persuade him to sign the bill anyway.

“It increases total defense spending by more than $60 billion from last year, and funds the addition of critically needed ships, planes, helicopters, tanks and submarines,” he said during brief remarks after signing the spending bill. “We have submarines being built the likes of which — there’s nothing anywhere in the world like the submarines we build.”