What happens if a P-type semiconductor contacts an N-type?

The contacting surface of P- and N-type semiconductors is a PN junction. 
When P-type and N-type come into contact, carriers, which are holes and free electrons, are attracted to each other, recombine at the junction of P-type and N-type, and disappear. Because there are no carriers near the junction, it is called a depletion layer, and it becomes the same state as an insulator. When voltage is applied by connecting P-type to "+" electrode and N-type to "-" electrode, electrons flow from N-type region to P-type region, electrons that did not disappear through recombination with holes move to “+” electrode, and current flows. The same mechanism applies to holes in P-type region.