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());
        }
    }
  • 相关阅读:
    Animation(三)
    布局
    AutoCommpleteText
    PHP数组中常用函数
    Animation(四)
    转:JAVA内存映射文件
    Ubuntu安装jdk
    转:Java NIO 详解
    转:长连接与短连接
    Direct or Nondirect ByteBuffer
  • 原文地址:https://www.cnblogs.com/angdh/p/15596584.html
Copyright © 2011-2022 走看看