Java passes args by value not reference. The swap method changed the values of the args it received, not the values of the variables whose values were passed to it.