There are direct train connections between Stansted Airport and Cambridge, but at some times it is quicker to take a local train towards London and change at Bishops Stortford or Stansted Mountfitchet. Check www.nationalrail.co.uk in advance, or when you get out from the baggage claim if you have a mobile device with a data plan that works in the UK.
The trip will take between 30 and 45 minutes, and most times of day you shouldn't need to wait more than half an hour for the train.
A ticket costs £10.40, and for this relation it does not get cheaper by buying in advance. The same ticket will be valid whether you catch a direct train or one with a change, so you don't need to know which train you will manage to catch when you buy a ticket at the machine.
Most of the trains are operated by Greater Anglia, but one train per hour is run by CrossCountry. The ordinary tickets you buy from the Greater Anglia ticket machines at the station are valid on CrossCountry too.