Specifically the commanding officer of a military vessel. Not used for civilian ship captains (船長).
艦長は乗組員に総員配置を命じた。
The captain ordered the crew to general quarters.
He serves as the captain of this submarine.
彼は巡洋艦の艦長に任命された。
He was appointed captain of a cruiser.
She became the youngest captain in history.
艦長 commands a warship, whereas 機長 is the captain (pilot-in-command) of an aircraft, so the two are easy to confuse by role but differ by vehicle type.
Used for people, especially in formal contexts such as positions, reservations, or seating.
Compound of 艦 (warship) and 長 (chief, head).