package com.java1234.test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.java1234.service.JavaWork;import com.java1234.test.HelloWorld;
public class Test2 {
public static void main(String[] args){
ApplicationContext ac=new ClassPathXmlApplicationContext("beans.xml");
JavaWork javaWork=(JavaWork)ac.getBean("javaWork");
javaWork.doTest();}}
package com.java1234.test;import com.java1234.service.JavaWork;import com.java1234.service.Lisi;import com.java1234.service.ZhangSan;
public class Test {
public static void main(String[] args){
JavaWork javaWork=new JavaWork();
// javaWork.setTester(new ZhangSan());
javaWork.setTester(new Lisi());
javaWork.doTest();}}
package com.java1234.test;
public class HelloWorld {
public void say(){
System.out.println("Spring4大爷你好!");}}
package com.java1234.service;
public class ZhangSan implements Tester{
public void test(){
System.out.println("张三-测试程序");}}
package com.java1234.service;
public interface Tester {
public void test();}
package com.java1234.service;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.java1234.test.HelloWorld;
public class Test {
public static void main(String[] args){
ApplicationContext ac=new ClassPathXmlApplicationContext("beans.xml");
HelloWorld helloWorld=(HelloWorld)ac.getBean("helloWorld");
helloWorld.say();}}
package com.java1234.service;
public class Lisi implements Tester{
public void test(){
System.out.println("李四-测试程序");}}
package com.java1234.service;
public class JavaWork {
private Tester tester;
public void setTester(Tester tester){
this.tester = tester;}
public void doTest(){
// ZhangSan zhangsan=new ZhangSan();
// zhangsan.test();
tester.test();}}
503.下一个更大元素II
力扣题目链接(opens new window)
给定一个循环数组(最后一个元素的下一个元素是数组的第一个元素),输出每个元素的下一个更大元素。数字 x 的下一个更大的元素是按数组遍历顺序,这个数字之后的第一个比它更…