Tax and stock earnings

If I was to make a profit from one stock with in less than a year but immediately put it into another, would I need to pay the taxes on the previous earnings?