zoukankan      html  css  js  c++  java
  • 方法引入2

    package com.mayikt.service;
    
    import com.mayikt.entity.UserEntity;
    
    /**
     * @ClassName Entity
     * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
     * @Version V1.0
     **/
    public interface UserInterface {
        UserEntity getUser();
    }
    package com.mayikt.entity;
    
    /**
     * @ClassName UserEntity
     * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
     * @Version V1.0
     **/
    public class UserEntity {
        private String userName;
        private int age;
    
        public UserEntity() {
    
        }
    
        public UserEntity(String userName, int age) {
            this.userName = userName;
            this.age = age;
        }
    
        public String getUserName() {
            return userName;
        }
    
        public int getAge() {
            return age;
        }
    
        @Override
        public String toString() {
            return "UserEntity{" +
                    "userName='" + userName + '\'' +
                    ", age=" + age +
                    '}';
        }
    
        //    @Override
        public int hashCode() {
            return userName.hashCode();
        }
    
        public boolean equals(Object obj) {
            if (obj instanceof UserEntity)
                return userName.equals(((UserEntity) obj).userName) && age == (((UserEntity) obj).age);
            else
                return false;
        }
    }
    package com.mayikt.method;
    
    import com.mayikt.entity.UserEntity;
    import com.mayikt.service.UserInterface;
    
    /**
     * @ClassName Test014
     * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
     * @Version V1.0
     **/
    public class Test014 {
        public static void main(String[] args) {
    //        UserInterface userInterface = () -> new UserEntity();
            // 构造函数引入  函数接口返回类型 UserEntity::new.----默认的情况下执行无参构造函数
            UserInterface userInterface3 = UserEntity::new;
            System.out.println(userInterface3.getUser());
        }
    }
  • 相关阅读:
    bzoj4543 长链剖分
    tarjan算法
    uoj36 玛里苟斯 高斯消元做法
    狄利克雷卷积
    斜率优化
    将一个工作簿拆分为多个工作表
    如何制作Excel斜线表头
    逻辑函数(IF函数)
    逻辑函数(AND,OR,NOT)
    Excel中提取英文,数值和编码(LEN函数)
  • 原文地址:https://www.cnblogs.com/angdh/p/15596584.html
Copyright © 2011-2022 走看看