java没有引用传递,不过可以通过对象的方式来实现引用传递:
- public class test1
- {
- public static void change(int[] counts) {
- counts[0] = 6;
- System.out.println(counts[0]);
- }
-
- public static void main(String[] args) {
- int[] count = { 1, 2, 3, 4, 5 };
- change(count);
- System.out.println(count[0]);
- }
- }
复制代码
|