When you exchange or trade property of the same nature or character, it's called a like-kind or Section 1031 exchange, which gets reported on IRS form 8824. The property exchanged must be held for investment purposes or for productive use in a trade or business.
Generally speaking, any taxable gain from a like-kind exchange is deferred unless it involves other property or cash. Losses on like-kind exchanges aren't usually recognized.
Right now, like-kind exchange treatment only applies to real property (real estate) as a result of the Tax Cuts and Jobs Act of 2017. Prior to the Act, personal property assets such as machinery, equipment, and vehicles, arts and collectibles, and some types of intangible property also qualified for like-kind exchange treatment.