Advertisement
Kotuara

Практика7.4

Dec 23rd, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.function.Consumer;
  4.  
  5. public class Main {
  6.  
  7.     public static class HeavyBox {
  8.         public int weight;
  9.  
  10.         public HeavyBox(int weight) {
  11.             this.weight = weight;
  12.         }
  13.     }
  14.  
  15.     public static void main(String[] args) {
  16.         HeavyBox Box1 = new HeavyBox(237);
  17.  
  18.         Consumer<HeavyBox> Ref = (HeavyBox Box) -> {
  19.             System.out.println("Отгрузили ящик весом " +Box.weight);
  20.         };
  21.  
  22.         Consumer<HeavyBox> Ref2 = (HeavyBox Box) -> {
  23.             System.out.println("Отправляем ящик весом " +Box.weight);
  24.         };
  25.  
  26.         Ref.andThen(Ref2).accept(Box1);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement