JAVA中两个int类型的变量在不借助第三个变量的情况下完成值的互换
摘要:在面试中被问到这个问题,想到两种解决方式,在此分享一下。 第一种,使用简单的数学运算达到目标(但是面试官往往会问你还有没有其他方式): public static void main(String[] args) { int a = 1; int b = 2; System.out.println(
阅读全文
posted @ 2021-01-30 23:19