package com.ruoyi.demo.service.impl;
//这个是注解,注解了之后,这个方法,没有其他第二种抽象方法,除了默认和eq方法之外
class MyClass implements TestInterFace3{
public int testMethod2(int num1 , int num2) {
System.out.println("我重新实现了testMethod方法!");
interface TestInterFace2{
void testMethod2(int num);
interface TestInterFace3{
int testMethod2(int num1 , int num2);
boolean equals(Object obj);
public static void main(String[] args) {
/* TestInterFace t = new MyClass();
/*TestInterFace t = new TestInterFace() {
public void testMethod() {
System.out.println("我重新实现了testMethod方法11111!");
/* TestInterFace t = () -> System.out.println("lambda表达");
/* TestInterFace2 t2 = (int num) -> System.out.println("这个方法得参数:"+num);
/* TestInterFace2 t2 = num -> System.out.println("这个方法得参数:"+num);
/* TestInterFace2 t2 = () -> {
String s = t2.testMethod2();
System.out.println(s);*//*
TestInterFace3 t = (x,y) ->{
System.out.println("俩个参数的值分别"+ x + y);
int i = t.testMethod2(3, 5);
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
void buy(BigDecimal money);
public static void bath(BigDecimal money,SpendMoney spendMoney){
public static void main(String[] args) {
bath(new BigDecimal(100), new SpendMoney() {
public void buy(BigDecimal money) {
System.out.println("本次按摩消费为"+money);
bath(new BigDecimal(100),
public static void bath(BigDecimal money,Consumer<BigDecimal> spendMoney){
spendMoney.accept(money);
public static void main(String[] args) {
bath(new BigDecimal(100), new Consumer<BigDecimal>() {
public void accept(BigDecimal bigDecimal) {
System.out.println("本次按摩消费为"+bigDecimal);
bath(new BigDecimal(100), x -> System.out.println("本次按摩消费为"+x) );
public static void main(String[] args) {
Consumer<String> con = x -> System.out.println("去啥地方了?"+x);
PrintStream out = System.out;
Consumer<String> con2 = out::println;
Consumer<String> con3 = System.out::println;
Comparator<Integer> con4 = (x, y) -> Integer.compare(x,y);
System.out.println(con4.compare(1, 3));
Comparator<Integer> con5 = Integer::compare;
System.out.println(con5.compare(434, 3));
BiPredicate<String,String> bp = (x,y) -> x.equals(y);
System.out.println(bp.test("asb", "aa"));
BiPredicate<String,String> bp2 = String::equals;
System.out.println(bp2.test("asb", "asb"));