//LinJie //Ten years Hello world,actually writing is life ! //Original //First year public class LinJie{ public static void main(String[] args) { //hello world System.out.println("hello world"); } } //Second years public class LinJie{ public static void main(String[] args) { //hello world LinJie obj = new LinJie(); obj.toString(); } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "hello world"; } } //The third year public class LinJie{ private static LinJie instance; public static LinJie getInstance() { if(instance == null) instance = new LinJie(); return instance; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "hello world"; } public static void main(String[] args) { //hello world LinJie obj = LinJie.getInstance(); obj.toString(); } } //Fourth years public class LinJie{ private final String a; //required private final String b; //required private final String c; //optional private final String d; //optional //Builder public static class Builder{ //required private final String a; private final String b; //optional private String c; private String d; public Builder(String a,String b) { this.a = a; this.b = b; } public Builder c(String val) { c = val; return this; } public Builder d(String val) { d = val; return this; } public LinJie build() { return new LinJie(this); } } private LinJie(Builder builder) { a = builder.a; b = builder.b; c = builder.c; d = builder.d; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return c+" "+d; } public static void main(String[] args) { //hello world LinJie obj = new LinJie.Builder("lin", "jie"). c("hello").d("world").build(); System.out.println(obj.toString()); } } //Fifth years /* <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="linjie" class="com.linjie.LinJie"></bean> </beans> */ public class LinJie{ @Test public void test() { //hello world ApplicationContext context = new ClassPathXmlApplicationContext ("applicationContext.xml"); LinJie obj = (LinJie) context.getBean("linjie"); obj.hello_world(); } public void hello_world() { System.out.println("hello world"); } } //Sixth years /* <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 扫描 --> <context:component-scan base-package="com.linjie.aop"> </context:component-scan> </beans> */ @Component("linjie") public class LinJie{ @Test public void test() { //hello world ApplicationContext context = new ClassPathXmlApplicationContext ("applicationContext.xml"); LinJie obj = (LinJie) context.getBean("linjie"); obj.hello_world(); } public void hello_world() { System.out.println("hello world"); } } //Seventh years /* <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <context:component-scan base-package="com.linjie.aop"> </context:component-scan> <aop:aspectj-autoproxy></aop:aspectj-autoproxy> </beans> */ /* @Component("arithmetic") public class Arithmetic { public void hello_world() {} } */ @Aspect @Component("linjie") public class LinJie{ @Test public void test() { //hello world ApplicationContext context = new ClassPathXmlApplicationContext ("applicationContext.xml"); LinJie obj = (LinJie) context.getBean("linjie"); obj.hello_world(); } @Before("execution(* com.linjie.aop.Arithmetic.*(..))") public void Before_Loggin() { System.out.println("hello world"); } } //Eighth years fail //Ninth years fail //Tenth years public class LinJie { public static void main(String[] args) { String grow = "hello world"; String grow_up = "hello world"; String grow_up_up = "hello world"; if(grow.equals(grow_up) && grow.equals(grow_up_up)) System.out.println(grow); } }