Although gun was introduced from Europe in the middle of 16th century, Japanese sword, Katana was used till the 19th century as the main weapon by the samurai. The production of Katana is divided into two major times. Koto(old sword) till 1596 and Shinto(new sword) from 1596.
Length between 60cm and 90cm is called tachi, and it was used by samurai on horses and it was the major katana till 1596. Then, tachi was hung from the belt with the cutting-edge down.
Uchigatana is between 60 cm and 70cm and it was carried by samurai and also designated civilians. Uchigatana was used for hand to hand combat, battle on foot. It became major katana after 1596, especially during Edo era when Tokugawa shogunate ruled Japan and there was no big battle at all. Not like tachi, uchigatana was hung from the belt with the cutting-edge up.
Then, katana was banned to carry in 1876, except officials wearing court dress of Empire of Japan and uniformed soldiers and police officers. Ban of carrying katana was the end of the era of samurai.