Yes, but learn to swim and tread water at the same time. If you’re going to spend time in the water, why not train both. Treading water is an important skill, and one that needs to be mastered. Becoming good at treading water is partly a mental fitness as well as physical. As a matter of fact, I can tread water barely moving my arms and legs, and my arms can be above water holding a 30 round fully equipped AR-15 (5-10 lbs is the usual test for the military) while treading water.
One of the reasons most people cannot tread water for more than 10 minutes, and they tire out physically, is they panic mentally thinking that they will drown if they stop moving. First thing to do is calm down, breathe, and let the air in your lungs control your buoyancy. Once you get the subtle rhythm of moving your legs and arms slowly as you control your breathing, you will tread water with minimal movement. This will keep you afloat for a very long time. The eggbeater method of treading water will burn too much energy so learn to calm your body and mind to move very little while treading water. The PADI divemaster test is 15 minutes of treading water and the last 2 minutes with arms up in the air out of the water. Try to at least get to that goal but add a 5-10 lb kettle bell, dumb bell, or medicine ball for the last 2 minutes with the arms in the air.