publicclassStatic_test
{
staticString color="green ";
public Static_test(String color)
{
this.color+= color;
}
publicstaticvoidmain (String[] args)
{
Static_testt1=newStatic_test("yellow ");
Static_test t2=newStatic_test("red");
System.out.println(t1.color);
System.out.println(t2.color);
System.out.println(color);
}
}
color is a Grobal Valiable. When the program come to
Static_testt1=newStatic_test("yellow");
it become green yellow
and next line ,it become green yellow red
where I did wrong :I thought it become green yellow but become green red next ,I forgot it's a grobal valiable.