Is it possible to write swap method in Java?

java, primitive-types, swap

Solution

Without using an array or objects, no, it is not possible to do it within a method.

Problem

Here is the question: write a method that swaps two variables. These two variables should be primitives. It doesn't need to be generic e.g. two `int` variables. Is there a way?!

Original source

Related problems