Mathematical puzzles

Puzzles, situation puzzles and recreational mathematics.

situation puzzles and recreational mathematics. Neuron juice

Neuron juice.

The important thing is not to stop questioning. (Albert Einstein.)

Riddle. 5.- On a table there are three black hats and two white ones.

Three men in a straight line put on a hat each one randomly and without knowing its colour.

The third one in the line, who can see the other ones' colour, is asked if he can tell his hat's colour —he says no.

The second one, who can only see the first one's hat, is asked the same question but can't tell his colour.

Finally, the first one, who can see no hat, tells correctly the colour of his hat.

Which is his colour and how could he know it?