Economists here will remember 1984 as the year in which Japan finally left behind the second oil shock and put real growth back above the 5 percent mark. Healthy expansion is expected to continue through 1985, though at a somewhat slower pace.

Although Japan is today the noncommunist world's second-largest economy, forecasters in its banks and government agencies still make their calculations with one eye on the United States, the most important market.

They say that a boom in exports spawned by recovery in the United States will taper off in 1985, and Japan's own domestic demand will take over as the main expansionary force, but its pull will not be as strong.

"Nineteen eighty-four was a year led by exports," observed Kazuo Kida, chief economist at Sumitomo Bank. "This year will be led by investment at home." Most analysts predict that real growth in 1985 will be at least one percentage point below 1984's 5.5 percent.

Nonetheless, Japan's foreign trade surplus will continue to grow. With the United States alone, the figure came to $33.11 billion in 1984, according to new Japanese reports -- almost double 1983's level -- and it, too, is expected to keep moving up.

In the international forum, friction with trading partners seems certain to increase. But at home, Japan seems set to register another year of the orderly, low-inflation growth that is so envied by the United States and other industrialized countries.

Nineteen eighty-four turned out better than expected (postwar projections here traditionally have erred on the conservative side). The 5 1/2 percent level compares with growth levels of 3 and 4 percent since 1979, the year the Iranian revolution touched off a second international oil crisis.

Exports rose 16 percent to a record $170 billion last year. Imports managed only an 8 percent rise, to reach $136 billion, only the third-largest annual figure on record. The resulting $34 billion net surplus compares with 1983's $21 billion.

Japan's sales to the United States alone, meanwhile, soared by 40 percent to reach $60 billion as the U.S. recovery gained momentum and consumers and companies went on a buying spree. VCRs, electrical machinery, telecommunications equipment and computers flooded into the United States, aided by the continuing weakness of the Japanese yen. Imports from the United States were up 9 percent to $27 billion.

Economists say that demand created by new exports accounted for the majority of Japan's growth in real GNP last year. But the consensus here is that that is going to change. "A rather major deceleration is likely to take place with respect to U.S. expansion," said Akinori Marumo of the government's Economic Planning Agency.

The Bank of Tokyo predicts that Japanese real export growth will recede to about 6 percent in 1985 and that import growth also will fall fast, to about 4 percent in real terms. Figures vary, but everyone agrees that the trade surplus will grow. The Mitsubishi Research Institute, for instance, is predicting a 1985 worldwide surplus of $52 billion.

Marumo expects that exports in the high-tech sector will continue to grow faster than exports as a whole. He also predicts that imports of manufactured goods will grow faster than imports as a whole, following last year's pattern. Machinery imports, for instance, grew by 16 percent in 1984.

Foreigners call Japanese import barriers the prime cause of the deficits. But the Japanese argue that it lies primarily in poor competitiveness and marketing by foreign companies as well as the continuing weakening of the yen. The yen opened 1984 in the 230 per dollar range, but in the first weeks of 1985 it was hovering just under 255, its weakest level in two years.

In May, the United States and Japan signed a detailed agreement to open Japan's vast capital markets to the outside world. It also was intended, in the long run, to strengthen the yen by encouraging demand for it as a reserve currency and medium of international trade.

But in the short run, the expectation here is for the reverse. "There is little hope of a change in the yen's undervalued position vis-a-vis the dollar in the coming year," says Mitsubishi's new year's outlook. Official government forecasts prudently avoid taking a position.

Officials here point out that, in the overall balance of payments, it is Japan that is in the red. Record volumes of capital -- more than $50 billion -- flowed out of Japan in 1984, much of it to buy U.S. government securities, which yield about five percentage points more than government instruments here.

"The entire world is suffering from a shortage of investment capital," said the Economic Planning Agency's Marumo. Japan has stepped in to play the role of "provider of investment funds to the outside world."

But Marumo and others say that an outflow of this volume cannot sustain itself indefinitely. The Bank of Tokyo is predicting that capital outflow will decline in 1985 to the point that Japan's overall balance of payments will be roughly in equilibrium. The Japanese say that the main question is whether the United States succeeds in controlling interest rates.

With export growth losing steam, Japan is falling back on its $1.2 trillion domestic economy for expansionary pull. With profitability up, Japanese companies last year enjoyed a boom in capital investment. Overall growth was about 10 percent, although it was far higher in the electronics and information industries. New investment in semiconductor plant and equipment alone will register a staggering 90 percent gain in the year ending March 31, according to Kida of Sumitomo Bank.

That boom, too, already has peaked, but will remain a major force in the economy in 1985, economists believe.