I was asked to explain why the linewont work. I figure the constructor is not being triggered but the why, beats me. Anyone care to explain?Code:System.out.println("" + x[2].getN());
Code:class Num{ private int n; public int getN(){ return n;} public Num( ){ n = 4; } } public class Main { public static void main( String[] args){ Num [] x = new Num[7]; System.out.println("" + x.length); System.out.println("" + x[2].getN()); } }




Reply With Quote