Firearms were present in Japan beginning in the 13th century, but saw little adoption. In 1543, the Portuguese introduced matchlock firearms, a much more impressive weapon, and Japan embraced them. They began manufacturing them in great numbers, researching firearms technology, and fielding armies equipped with firearms, which they used to great effect. In 1592 a Japanese force invaded Korea and rapidly captured Seoul, in large part due to the presence of an estimated 40k gunners in the force. It's estimated Japan may have led the world during this period in firearm production, and surviving written records suggest they saw firearms very positively.
...then, they stopped. There's an excellent book about it called "Giving Up The Gun" (https://www.amazon.com/Giving-Up-Gun-Reversion-1543-1879/dp/...) There's no super clear explanation; the answer mostly seems to be a vague hand-wavy nod towards "cultural reasons".
But, obviously, those cultural reasons didn't seem to apply prior to the Edo period, when Japan went all-in on firearms, arguably more so than any European country. Odd.