There were two words President Obama didn't say during his commencement address at Rutgers University Sunday afternoon: Donald Trump.

But the presumptive GOP nominee was at the heart of Mr. Obama's speech, which focused in large part on the "ignorance" pervading American politics today.

"Facts. Evidence. Reason. Logic. An understanding of science," Mr. Obama said. "These are good things. These are qualities you want in people making policy. These are qualities you want to continue to cultivate in yourselves as citizens."

Get Breaking News Delivered to Your Inbox

"We traditionally have valued those things, but if you were listening to today's political debate, you might wonder where this strain of anti-intellectualism came from," he continued. "So class of 2016, let me be as clear as I can be: in politics and in life, ignorance is not a virtue. It's not cool to not know what you're talking about. 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. And yet we've become confused about this."

Referring, undoubtedly, to Trump's frequent calls for a wall to be built between the United States and Mexico, Mr. Obama said keeping the rest of the world out won't fix the problems at home--or keep out bad things happening around the world.

"The world is more interconnected than ever before and it's becoming more connected every day," Mr. Obama said. "Building walls won't change that."

He went on to criticize Trump's worldview, saying that in an increasingly interconnected world, the United States can't operate in isolation. The threat of ISIS, or diseases like Zika and Ebola, aren't contained by country borders, he said.

"Look, as president my first responsibility is always the security and prosperity of the United States, and as citizens we all rightly put our country first," he said. "But if the past two decades have taught us anything, it's that the biggest challenges cannot be solved in isolation."

He spoke about the dangers of, for example, stopping trade with certain countries abroad--another implicit reference to Trump's proposed policies. "In this global economy, that isn't even possible," he said. "The answer is to do trade the right way."

In another not-so-subtle reference to Trump and his suggestion that Muslims should be temporarily barred from entering the U.S., Mr. Obama said "disparaging" Muslims runs counter to core American ideals and beliefs.

"Isolating or disparaging Muslims, suggesting they should be treated differently when entering this country--that is not just a betrayal of our values, that's not just a betrayal of who we are, it would alienate the very communities at home and abroad that are our most important partners in the fight against violent extremism," he said.

Mr. Obama told the graduates that democracy is difficult, but that in order to continue the country's progress they need to participate.

"Have faith in democracy," he said. Look, I know it's not always pretty, really, I know. I've been living it. But it's how bit by bit, generation by generation, we have made progress in this nation."