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());
        }
    }
  • 相关阅读:
    发现可高速缓存的 SSL 页面
    启用了不安全的HTTP方法
    目录遍历漏洞
    强强合体:Docker版Kali Linux发布
    Kali2.0 Sqlmap清除历史扫描日志
    OWASP-ZAP
    基于web的项目管理软件Redmine
    sqlmap用户手册
    Sqlmap基础(二)
    信息存储安全
  • 原文地址:https://www.cnblogs.com/angdh/p/15596584.html
Copyright © 2011-2022 走看看