Suppose we have a machine that can record a complete description of the arrangement of molecules inside a person’s brain, as well as all their psychological states – their beliefs and desires, their feelings, their memories, and their character traits. Moreover this machine can also reconfigure people's brains and psychology to match any that it has recorded. Suppose we use this machine to transfer Barry's psychology to Gary's body, and Gary's psychology to Barry's body.
So now, the person in Gary’s body is psychologically continuous with Barry – he has all of Barry’s beliefs, desires, memories and character traits, and presumably will ‘feel like’ Barry – and vice versa.