java吧 关注:1,251,394贴子:12,735,218
  • 7回复贴,共1

来来来,j8的大神门,来看看这个问题,我真是搞不懂了,醉了

只看楼主收藏回复

public class Text {
public static int k =0 ;
public static Text t1 = new Text("t1") ;
public static Text t2 = new Text("t2") ;
public static int i = print("i") ;
public static int n =99 ;
public int j = print("j") ;
{
print("构造块");
}
static {
print("静态块");
}
public Text(String str){
System.out.println((++k)+":"+str+" i="+i+" n="+n) ;
++i;++n ;
}
public static int print(String str){
System.out.println((++k)+":"+str+" i="+i+" n="+n) ;
++n;
return ++i ;
}
public static void main (String args[]){
Text t = new Text("init") ;
}
}
输出神马。。。。。。。。。。。。


IP属地:陕西1楼2014-11-05 18:24回复
    1:j i=0 n=0
    2:构造块 i=1 n=1
    3:t1 i=2 n=2
    4:j i=3 n=3
    5:构造块 i=4 n=4
    6:t2 i=5 n=5
    7:i i=6 n=6
    8:静态块 i=7 n=99
    9:j i=8 n=100
    10:构造块 i=9 n=101
    11:init i=10 n=102
    居然可以运行,可是实在不懂怎么来的,求大神告知


    IP属地:陕西2楼2014-11-05 18:37
    回复
      求解释


      IP属地:陕西3楼2014-11-05 18:52
      回复
        ……


        IP属地:陕西来自Android客户端4楼2014-11-06 09:23
        回复
          啥东西


          来自Android客户端5楼2014-11-08 15:29
          收起回复


            IP属地:陕西来自Android客户端6楼2014-11-08 16:15
            回复