是否可以在Java中编写swap方法? [英] Is it possible to write swap method in Java?
本文介绍了是否可以在Java中编写swap方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个问题:编写一个交换两个变量的方法。这两个变量应该是原语。它不需要是通用的,例如两个 int
变量。有没有方法?!
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?!
推荐答案
不使用数组或对象,不可以在方法中执行。
Without using an array or objects, no, it is not possible to do it within a method.
这篇关于是否可以在Java中编写swap方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文