package com.brains.reactivejavademo;
import java.time.LocalDateTime;
import java.util.concurrent.Callable;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
public class T1 {
private static Callable callable(){
return () -> "Callable: hello";
}
private static Runnable runnable = () -> System.out.println("Runnable: This is runnable");
private static Supplier supplier = () -> "Supplier";
private static Consumer consumer(){
return s -> System.out.println("Consumer : "+s);
}
private static Function func(){
return (s) -> s.concat(String.valueOf(s.length()));
}
private static BiFunction bifunc(){
return (s,r) -> s.concat(r);
}
public static void main(String[] args) throws Exception {
// callable
Callable s = callable();
System.out.println(s.call());
//-- Callable: hello
// runnable
runnable.run();
//-- Runnable: This is runnable
String s1 = supplier.get();
System.out.println(s1);
//-- Supplier
// consumer
consumer().accept("abc");
//-- Consumer : abc
String function = func().apply("hello");
System.out.println(function);
//-- hello5
String bifunction = bifunc().apply("helo", "world");
System.out.println(bifunction);
//-- heloworld
}
}
Leave a Reply