Young people want to save for the future, and about a third of them believe the best way to do that is to stockpile cash.

That’s according to a new survey from Bankrate, which found that 30 percent of millennials (those aged 18 to 37) say cash is the best place to put money they won’t need for 10 years or more. Just 21 percent of those 38 and older say the same.

Less than a quarter of millennials cite investments in the stock market as the No. 1 way to store money long-term, even though that's what experts recommend. Close to 77 percent favor other options, including cash, real estate, gold and bitcoin. That’s a mistake that could cost them thousands, or even millions, of dollars, especially considering that millennials are expected to have the biggest retirement savings burden in history, Greg McBride, Bankrate’s chief financial analyst, tells CNBC Make It.

“You can’t save enough to get the nest egg you’ll need in retirement without the benefit of the power of compounding,” McBride says.

“The buying power of your investments is going to get eaten away by inflation by about 2 percent to 3 percent per year,” McBride says. “So you’ve got to earn at least that much to preserve the buying power.”

Many millennials are hesitant to enter the market, however, and Bankrate posits that younger people prefer cash because it’s hard to imagine owning funds they won’t touch for decades. Their nervousness also makes sense, given their experiences: Many millennials have seen investments collapse.

“A lot of it is being shell-shocked of coming of age during the financial crisis,” McBride says, adding that older millennials also witnessed a similar event with the dot com crash in the early 2000’s. “To see that once or twice within a period of a few short years understandably scared a lot of investors out of stocks altogether.”

But although the stock market can be volatile, history shows that investing almost always pays off: Over the past 90 years, the average annual return for the S&P 500 is over 9 percent.