Prime Minister Yasuhiro Nakasone's observation in a speech on Monday that the level of education and intellect in the United States is low because of its large black and Hispanic populations almost passed unnoticed here.

Some of Japan's nationally circulated newspapers made no mention of it. Those that did generally put it in inside-page columns that chronicle off-beat or humorous developments in the political world.

In the view of many Japanese, Nakasone was simply talking common sense, saying that ethnic diversity creates confusion and discord and that societies function best when people look, think and act alike, as they do in Japan.

The uproar the prime minister's words caused the next day in the United States forced Japan to sit up and pay attention. Facing angry speeches in Congress and calls for a boycott of Japanese products, Nakasone yesterday acknowledged formally that he had offended many Americans and issued a "heartfelt apology."

His gesture appeared to cool things off. But it did little to close the gap of racial perceptions that permanently divides the two countries. In the United States, Nakasone's remarks were called racist; in Japan, he is faulted mainly for voicing his opinion, not for having it.

Nakasone said he was only making an objective statement about literacy and intended no slur. Racial equality is Japan's official objective, but many Japanese analysts fear similar incidents are inevitable.

"We are not accustomed to living together with other races," lamented Tadashi Yamamoto, president of the Japan Center for International Exchange. "We do not have the basic training."

Many Japanese think big decisions are easier in a homogeneous society.

"The racial composition of Japan's population is highly uniform," the mass-circulation Asahi Shimbun newspaper editorialized today, "and this has been a favorable factor in the spread of education and in the development of the economy."

The Japanese government is eager to preserve this purity, many analysts said, and uses strict immigration laws as a tool. Although Japan has been generous with money to support Indochinese refugees in third countries, for instance, it has resettled only about 4,700 of them here.

On a personal level, things can work in a similar way. Japanese who have lived overseas for extended periods are often vaguely distrusted by other Japanese when they return. Companies may refuse to hire them, out of fear they will not offer the requisite sacrifice and loyalty.

With foreigners as individuals, the Japanese display a peculiar mix of approach and avoidance.

They feel most comfortable with white Americans and Europeans, who are held to have superior intellect in certain technical fields and better taste in fashion and style generally. White faces show up everywhere in advertising, for instance. But at the same time, white foreigners find Japanese reluctant to sit next to them on the subway. Some Japanese bars post signs outside barring foreigners' entry.

Black baseball players are cherished members of Japanese teams and black musicians are slavishly interviewed on television. But on the housing market, blacks can run into the same problems they do in the United States. Some Tokyo landlords turn blacks away while accepting white foreigners. In general, blacks get a colder reception than do whites.

But in the end, any type of foreigner finds it all but impossible to form a deep friendship with a Japanese, even if there is no language barrier. At one level there is courtesy and receptiveness, but at the next, a brick wall.

Many Japanese are not much closer to the domestic minorities that make up only about 3 million of the 120 million population. The largest group is the burakumin, or "village people," descendents of a feudal outcast class that took occupations considered unclean such as leather tanning and slaughtering animals. They number 2 million or more and remain in many of the old occupations.

Government spending is helping to raise their standard of living. But ordinary Japanese avoid contact with them. Racially they are no different, however. For that reason, a special class of private detectives exists for the purpose of investigating the backgrounds of potential in-laws.

Koreans number about 650,000 and came here during Japan's 1910-1945 colonial rule of their country and remain an economic underclass today. They are viewed by many Japanese, particularly the older generation, as loud, ill-mannered and prone to crime. Other groups are the Chinese, with about 50,000, and about 20,000 Ainu, all that is left of the aboriginal inhabitants of northern Japan.

But much is heard these days of Japan's "internationalizing." Formal trade barriers are coming down. More foreign restaurants are opening. More English is spoken. In increasing numbers, Japanese are taking their vacations abroad. Nakasone is talking of increasing the number of foreign students here tenfold, to 100,000.

Island geography and deliberate isolationism encouraged evolution of a distinctive Japanese identity in ancient times. Since the end of World War II, technology, economics and calculated decisions by government and individuals have helped to keep it strong.

National radio and television dilute regional accents. Company employes being shuffled around the country by the millions are breaking up regional loyalties. Education is centrally directed. One of the world's most equitable distributions of income has softened class lines.

During the war, the Japanese were taught that their race had a divine mission to rule and bring prosperity to all of Asia. That thinking is largely gone, but many people here retain a feeling that the Japanese are unique in the world, a tiny island community with no resources where prosperity is possible only through unity.

"Deep down, we have a feeling that foreigners can never fully understand Japanese culture," said Hidekazu Kawai, a political science professor at Tokyo's Gakushuin University.

Physiological explanations have been offered for this uniqueness. One that surfaces here from time to time is a theory that the Japanese brain develops differently from other human brains during childhood, due to the intensely difficult dual writing system of phonetics and ideographic Chinese characters.

Still, there are signs of change. The burakumin have a "liberation movement" that stands up militantly whenever it feels its members' rights at stake. In July, the first naturalized Korean was elected to parliament.

What criticism there has been of the substance of Nakasone's comments has come mainly from opposition parties, which give the minorities a voice.

Tsuruo Yamaguchi, secretary of the Japan Socalist Party, called the remarks "insulting and full of malice," adding that "these words may even smell of narrow-minded nationalism or patriotism, like Hitler's." Yamaguchi said the affair reflected a similar insensitivity by Nakasone to Japan's own minorities.