There were three men in a line (facing forward) so they can only see the man (or men) in front of them. There are also five hats, two black and three white. Each man is wearing one of the hats.
When the man at the back of the line was asked "Do you know your hat color?", he replied "No". When the man that was second in line was then asked "Do you know your hat color?" he replied "No". When the man at the front of the line was asked "Do you know your hat color?" he replied "Of course".
What color of hat was the man at the front of the line wearing?
If the first and second wore black, the third would have known his hat was white; as he didn't know his color, he didn't see two black hats.
If the first wore black, the second would have known his hat was white (as if it had been black, the third would have known his own color); as the second didn't know his color, he didn't see a black hat... and thus the first one knows his color.