PISCATAWAY, N.J. — Without mentioning him by name, President Barack Obama used his commencement address Sunday at Rutgers University to attack what he said is an absence of facts fueling presumptive Republican nominee Donald Trump’s White House run and a “strain of anti-intellectualism” in current political discourse.

“It’s not cool to not know what you’re talking about,” the president told an audience of more than 50,000 at High Point Solutions Stadium on the central New Jersey campus. “That’s not keeping it real or telling it like it is. That’s not challenging political correctness. That’s just not knowing what you’re talking about.”

Obama helped Rutgers mark its 250th anniversary. His commencement speech was the first by a sitting president for the university.

The 44th president, who received an honorary Doctor of Laws degree Sunday from Rutgers, emphasized to the graduating students in red and black gowns the need to stay informed on the national and world stage.

“Facts, evidence, reason, logic, an understanding of science, these are good things. These are qualities you want in people making policy,” Obama said in remarks lasting about 45 minutes. “So class of 2016, let me be as clear as I can be: In politics and in life, ignorance is not a virtue.”

Obama denounced one of Trump’s most controversial campaign pledges — to build a wall on the southern border to help keep out undocumented immigrants, and to make Mexico pay for it. The president also criticized as anti-American what he said is the billionaire businessman’s anti-Muslim and anti-immigrant rhetoric.

“Suggesting that we can build an endless wall along our borders and blame our challenges on immigrants, that doesn’t just run counter to our history as the world’s melting pot,” Obama said. “It contradicts the evidence that our growth and our innovation and our dynamism has always been spurred by our ability to attract strivers from every corner of the globe.”

advertisement | advertise on newsday

He added later that the United States must continue to help others in order to help itself.

The president alluded to long shot Democratic presidential candidate Bernie Sanders, also though not by name. Obama said that contrary to the views of populists on the left and the right, “the system isn’t as rigged as you think and it certainly isn’t as hopeless as you think.”

New Jersey’s congressional delegation had sent numerous messages to the White House requesting the president’s presence, school officials said.

Obama in his speech commended the three-year campaign launched by Rutgers that successfully invited him to speak, saying that amid the flood of emails and YouTube videos, even the grandmother of the student body president sent him several notes.

Before the speech, students waited eagerly for Obama, who arrived via the Marine One helicopter to sustained cheers on a chilly and blustery afternoon.

Gabi Cozzolino, 22, of Mastic Beach, commended Obama for calling Rutgers students’ 2014 protest of former U.S. Secretary of State Condoleezza Rice as their would-be commencement speaker “misguided.”

“It was exactly what we needed to hear,” said the graduating political science student. “He spoke about acceptance and tolerance of everyone’s views.”

Obama said students could have heard out Rice and asked her tough questions as part of a healthy debate.