【自动化__持续集成】___java___static
一、代码如下
package www.wujianbotwo; public class Demo4 { public static void main(String[] args) { Demo4 demo4= new Demo4(); } static { System.out.println("static语句执行"); } public Demo4() { // TODO Auto-generated constructor stub System.out.println("Demo4构造语句执行"); } }
package www.wujianbotwo; public class Demo4 { public static void main(String[] args) { Demo4 demo4= new Demo4(); Demo4 demo5= new Demo4(); } static { System.out.println("static语句执行"); } public Demo4() { // TODO Auto-generated constructor stub System.out.println("Demo4构造语句执行"); } }
package www.wujianbotwo; public class Demo4 { public static void main(String[] args) { Demo4 demo4= new Demo4(); Demo4 demo5= new Demo4(); System.out.println(demo4); } static { System.out.println("static语句执行"); } public Demo4() { // TODO Auto-generated constructor stub System.out.println("Demo4构造语句执行"); } }
package www.wujianbotwo; public class Demo5 { static int age=-1; public static void main(String[] args) { // TODO Auto-generated method stub Demo5 demo5= new Demo5(); demo5.age=9; System.out.println(demo5.age); Demo5 demo6= new Demo5(); demo5.age=40; System.out.println(demo5.age); } }