• java高级教程 圆 圆柱 面积


    Test:

    package com.m.ioc;

    import org.springframework.context.ApplicationContext;

    import

        org.springframework.context.support.ClassPathXmlApplicationContext;

    public class Test {

        public static void main (String[] args) {

           ApplicationContext applicationContext= new ClassPathXmlApplicationContext("applicationContext.xml");

           UserDao userDao = (UserDao) applicationContext.getBean("userDao");

           userDao.say(3,3.14);

           userDao.say(5,3.14);

        }

     

    }

     

    Test01:

    package com.m.ioc;

    import org.springframework.context.ApplicationContext;

    import

       org.springframework.context.support.ClassPathXmlApplicationContext;

    public class Test01 {

        public static void main(String[] args){

           ApplicationContext applicationContext =

                  new ClassPathXmlApplicationContext("applicationContext.xml");

           UserService userService =

                  (UserService) applicationContext.getBean("userService");

           userService.say(4,18.84);

        }

     

    }

     

    UserDao.java:

    package com.m.ioc;

     

    public interface UserDao {

        public void say(int ll,double paipai);

    }

     

    UserDaoimp.java:

    package com.m.ioc;

     

    public class UserDaoimp implements UserDao{

        int l=4;double pai=3.14;

        public void say(int ll,double paipai)

        {

        l=ll;pai=paipai;

        System.out.println("底面周长是:"+(2*l*pai));

        System.out.println("底面积是:"+(l*l*pai));

        }

    }

     

    UserService.java:

    package com.m.ioc;

     

    public interface UserService {

        public void say(int h,double c);

    }

    UserServiceimp.java:

    package com.m.ioc;

     

    public class UserServiceimp implements UserService{

        double c=18.84;

        private UserDao userDao;

        public void setUserDao(UserDao userDao){

           this.userDao = userDao;

        }

        public void say(int h,double c){

        this.userDao.say(3,3.14);

        System.out.println("圆柱体积是:"+(c*h));

        }

    }

     

    Xml文件:

    <?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:p="http://www.springframework.org/schema/p"

        xsi:schemaLocation="http://www.springframework.org/schema/beans

            http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">

        <!-- 将指定类配置给Spring,让Spring创建其对象的实例 -->

        <bean id="userDao" class="com.m.ioc.UserDaoimp" />

        <bean id="userService" class="com.m.ioc.UserServiceimp" >

        <property name="userDao" ref="userDao" />

    </bean>   

    </beans>

     

  • 相关阅读:
    video全屏视频背景适配不同分辨率
    深入理解object.defineproperty()方法
    抓取之近似网页过滤
    基情四射的两个css样式
    Hadoop 2.4.1 登录认证配置小结
    Window中调试HBase问题小结
    改了改博客界面
    Hbase0.98.4/Hadoop2.4.1整合小结【原创】
    Hadoop 2.4.1 Map/Reduce小结【原创】
    hadoop的dfs工具类一个【原创】
  • 原文地址:https://www.cnblogs.com/1314-520/p/12635959.html
Copyright © 2020-2023  润新知