By heart

By memorizing.

The boy knows the poem by heart.