2013年10月7日星期一

Alibaba's pen questions, please explain to me the god of the n value.

Please write the output of the following program :
public class Test {
public static int k = 0;
public static Test t1 = new Test ("t1");
public static Test t2 = new Test ("t2");
public static int i = print ("i");
public static int n = 99;
public int j = print ("j");
{
System.out.print (" building blocks " ) ;
}
static {
System.out.print (" static constructor block" ) ;
}
public Test (String string) {
System.out.println ((+ + k) + ":" + string + "i =" + i + "n =" ; + n);
+ + i; + + n;
}
private static int print (String string) {
System.out.println ((+ + k) + ":" + string + "i =" + i + "n =" ; + n);
+ + n;
return + + i;
}
public static void main (String [] args) {
new Test ("init");
}
Here is the output :
1: j i = 0 n = 0
building blocks 2: t1 i = 1 n = 1
3: j i = 2 n = 2
building block 4: t2 i = 3 n = 3
5: i i = 4 n = 4
static constructor block 6: j i = 5 n = 99
building blocks 7: init i = 6 n = 100
My answer n values ​​are from 99-105 , seeking to explain , thank you much , ah ah minutes .
------ Solution ---------- ----------------------------------
fourth appearance in the forum , plus 2008 in that time, I figure should be the fifth time . . .
first
http://bbs.csdn.net/topics/390597457
second
http://bbs.csdn.net/topics/390605401
Third
http://bbs.csdn.net/topics/390606269
This is the fourth time you asked . . .
this title in 2008 when he was asked . . Or is the essence of the message added
http://bbs.csdn.net/topics/280036316
about this topic , you should first search my posts ask . . .
------ For reference only -------------------------------------- -
right. taught a ....

没有评论:

发表评论