First, June chooses a large number n such that n is the product of two primes p and q. She calculates two numbers, d and e, defined as follows. d and (p-1)(q-1) must be relatively prime, and de mod (p-1)(q-1) must equal 1. The set (d, n) is called the public key, and the set (e, n) is called the private key.
Now, June mails Rex d and n. This can be done in an insecure manner such as over the internet.
Rex now encodes the message. If the message is m, Rex calculates (m^^d) mod n and sends that to June. That message can be intercepted, but even if a malignant party knows d and n, he/she cannot decode the message.
Now, when June gets the message (call it C), she decodes it by calculating (C^^e) mod n.
Public key encryption is nice because it does not require a key to be sent by a secure means. It relies on the fact that n cannot be factored quickly. If it could, then e could be calculated rather quickly, and the code could be broken. This is why the number n must be huge.