class test
{
static x;
test()
{
x=x+1;
}
}
void main()
{
test[] a=new test[10];
System.out.println(test.x)//为什么还是0?}
{
static x;
test()
{
x=x+1;
}
}
void main()
{
test[] a=new test[10];
System.out.println(test.x)//为什么还是0?}
test[i] t=new test();}
}
单独new是这样写么 新手呵呵 请教
{
test[i]=new Test();
}加个这个循环语句打印出来就是10了,
static int x;
public test(){
x=x+1;
}
}
public class ok{
public static void main(String[] args){
test[] a=new test[10];
System.out.println(a[0]);
for(test t:a){
t=new test();
}
System.out.println(test.x);
test s1=new test();
test s2=new test();
System.out.println(test.x);
}
}