private问题
程序代码:
class Test{ private int[]age; public int[] getAge() { return age; } public void setAge(int[] age) { this.age = age; } }
在另一个类中怎么赋值给age[]
import java.util.Arrays; class Test{ private int[] age; public int[] getAge() { return age; } public void setAge(int[] age) { this.age = age; } } public class Test3 { public static void main(String[] args) { Test test = new Test(); test.setAge(new int[]{1,2,3,4}); System.out.println(Arrays.toString(test.getAge())); } }