In the previous chapter, we introduced and explained the concept of superposition. This concept does not exist in classical computing, and it is one of the reasons quantum computing is fundamentally different from classical computing. Nevertheless, we managed to describe superposition in such a way that a Java programmer can use it in their code. In this chapter, we introduce quantum entanglement, a concept that is also not encountered in classical computing and that makes quantum computing powerful. Again, we show how you can simulate quantum entanglement and deal with it by using Java code.
Have you ever been at a magic show where the magician was able to predict a property that seemed to be random? Maybe a spectator chose a card from a deck, and the magician said which card it was without seeing it. Or perhaps the spectator tossed a coin and hid the result, and the magician could tell whether the coin landed heads or tails.