"We live in a 21st century global economy. And in a global economy, jobs can go anywhere. Companies, they are looking for the best-educated people, wherever they live, and they will reward them with good jobs and good pay," the president said.
"We can just kind of shrug our shoulders and settle for something less, or we can do what America has always done, which is adapt. We pull together, we up our game, we hustle, we fight back, we work hard, and we win," he said.
Obama joked that he had asked students at the Brooklyn school if they could help him help his daughter Malia with her math homework.
"I don't know if some of you have experienced this where you get to the point where your children ask you for help and you suddenly realise you have no idea what's going on," he said amid laughter from his young audience.
The President said America has to educate its young people and prepare them for the global economy.
With the cost of higher education escalating, Obama said he is working hard to reduce the burden of student loans on young people.