Black does both...actually better than most other colours....
Old harleys and dirt bikes have black cylinders to dissipate heat more rapidly
Black piping on the roof for hot water for a pool collects heat more rapidly...
You figure out which one your needing to do and paint it black accordingly...
OK I think it goes like this...If the object your trying to cool is hotter than the ambient air then paint it black to dissipate heat more rapidly
If the object is needing to heat up more than something else...aka pipe as mentioned...it needs to be black to absorb more heat from the sun light....
Thats what I can remember of what was explained to me back in the 80s when I was in school and posed that question to a science teacher because I worked in a speed shop who swore that Black was only colour for engine to dissipate more heat!