When asked about volatile Chinese stocks, investing legend said Saturday that markets can sometimes resemble a "casino."

The Oracle of Omaha offered advice to the world's second-largest economy, which in recent years has struggled to manage the fallout from an economic slowdown. Chinese authorities have imposed capital controls, and tightly manage the levels of its currency, the yuan.

"Early on in the development of markets there's probably some tendency for them I think to be more speculative than markets that have been around for a couple hundred years," Buffett said, in response to a Chinese investor's question. He was speaking at the Berkshire Hathaway annual shareholders meeting.

"Markets have a casino characteristic that has a lot of appeal to people, particularly when they see people getting rich around them," Buffett said. "And those who haven't been through cycles before are more prone to speculate than people who have experienced the outcome of wild speculation."

The New York Stock Exchange launched in the late 18th-century. In contrast, the Shanghai Stock Exchange opened in 1990.

Shanghai composite 3-year performance

The plunged more than 40 percent in the summer of 2015 after rampant speculation came to a sharp end. Local investors, who borrowed heavily to buy stock, had to sell shares to pay back their creditors.

In the last several weeks, Chinese authorities have tightened regulation on financial markets, keeping stocks under pressure. The Shanghai composite is now flat on the year.

"If the market gets hot and people on leverage are doing well, a lot of people will be attracted not only to what I call speculation but what I call gambling," Buffett said, adding that mentality can be true in the U.S. as well.

"There's nothing more agonizing than to see your neighbor who you think has an IQ 30 points below you getting rich buying stocks," the investor joked.

However, "it will offer investors more opportunity if you have lots of speculation, if they keep their wits about them," Buffett said.

In a report last week, Wells Fargo Investment Institute said investors should diversify outside the U.S. and look for opportunities in places such as China.

That sentiment was echoed on Saturday by Berkshire Vice-Chairman Charlie Munger, who said in response to a separate question that China should do well in the long run, despite some growing pains.

"I do think the Chinese stock market is cheaper than the American market," he said. "I do think that China has a bright future."