It's dubbed the golden decade, when you're meant to be most carefree and at your happiest.
But being unhealthy in your 20s really could be detrimental to your health years later, US scientists have warned.
Researchers found young adults who smoked, experienced higher levels of stress and rarely exercised were twice as likely to have poor cognitive performance by the time they hit their 40s.
While some poor cognitive performance is expected with advanced age it can also be precursor to far more serious conditions like dementia.
Dr Kristine Yaffe, an expert in dementia and cognitive ageing at the University of California San Francisco, said: 'Inflammation plays a significant role in cognitive aging and may begin in early adulthood.
'There is likely a direct and indirect effect of inflammation on cognition.
'Fortunately, there are ways to reduce inflammation — such as by increasing physical activity and quitting smoking — that might be promising paths for prevention.'
Researchers analysed data from more than 2,300 adults aged between 18 and 30-years-old.
Over a follow-up of 18 years, they were each tested four times for C-reactive protein (CRP), a marker for inflammation.
They then took cognitive tests five years after their last CRP measurement, by which time most participants were in their forties and fifties.
The scientists found just 10 per cent of those with low inflammation scores in their 20s performed poorly on processing speed and memory tests.
But the figure stood at 21 and 19 per cent respectively, among those with either moderate or higher levels, according to the study published in the journal Neurology.
'We know from long-term studies that brain changes leading to Alzheimer’s disease and other dementias may take decades to develop,' Dr Amber Bahorik, an expert in psychiatry and cognition at the University of California San Francisco.
'We wanted to see if health and lifestyle habits in early adulthood may play a part in cognitive skills in midlife, which in turn may influence the likelihood of dementia in later life,' she added.
Around 944,000 people in the UK are thought to be living with dementia, while the figure is thought to be around seven million in the US.
Alzheimer's is the biggest cause of dementia affecting around six in ten of those with the condition.
It is thought to be caused by a build-up of amyloid and tau in the brain, which clump together and from plaques and tangles that make it harder for the brain to work properly.
Eventually, the brain struggles to cope with this damage and dementia symptoms develop.
The second most common form of dementia is vascular which is where there is a reduced blood flow to the brain such as stroke.
Memory problems, thinking and reasoning difficulties and language problems are common early symptoms of the condition, which then worsen over time.
Alzheimer's Research UK analysis found 74,261 people died from dementia in 2022 compared with 69,178 a year earlier, making it the country's biggest killer.