Most species of ants cannot swim. The Camponotus schmitzi, or diver ant, is an exception according to the National Institutes of Health. Even though many ants can't swim, they are usually excellent floaters.
Since ants are not proficient swimmers, they have been known to build rafts to help them survive on the water in times of floods. Fire ants are especially good at this. They link their bodies together and float on top of the water for as long as necessary until they can find a place to build a new home.
Diver ants regularly go into the water in search of food. These insects live inside pitcher plants and look for food inside the plant's digestive juices.