Can you build bone density by swimming?

Some not much . One of the biggest determinants of bone mineral density is lean body mass. Exercise is important for building lean body mass. Exercise is also important for putting load on your bones. This load is important for bone mass as bone strengthens as stresses are put upon it. Weight-bearing physical activity such as walking or running is better for building/ maintaining bone than non-weight-bearing activities such as swimming.
No. Swimming is a good aerobic exercise however, for bone weight bearing or resistance exercise is necessary.