Why trick does Huck play on Jim?

The trick that Huck plays on Jim is that he pretends that when he left it was all a dream of Jim and it never really happened.