在面试中被问到这个问题,想到两种解决方式,在此分享一下. 第一种,使用简单的数学运算达到目标(但是面试官往往会问你还有没有其他方式): public static void main(String[] args) { int a = 1; int b = 2; System.out.println("交换前:"); System.out.println("a = " + a); System.out.println("b = " + b); a
记得我在不知道Tuple时,如果想实现调用某个函数时,返回多个值,则需要使用ref或者out了. string name = ""; int result= GetInfo(ref name); public int GetInfo(ref string name) { name = "testName"; ; } 调用GetInfo()函数后,返回name=testName,result=2. C# 4.0后有了元组Tuple,可以将不同类型的数据都丢进去,并且一
Java中两个或多个byte数组合并及int类型转数组 // 用list好处是可以未知多个? public static byte[] test(List<byte[]> values) { int lengthByte = 0; for (byte[] value : values) { lengthByte += value.length; } byte[] allBytes = new byte[lengthByte]; int countLength = 0; for (byte[]