From d34c492adbf89db6d8663e5326970ba4427cf818 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Fri, 24 Jul 2020 15:58:41 -0400 Subject: [PATCH] LambdaEvens --- .../tests/others/LambdaEvensTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/test/java/com/ossez/codebank/interview/tests/others/LambdaEvensTest.java diff --git a/src/test/java/com/ossez/codebank/interview/tests/others/LambdaEvensTest.java b/src/test/java/com/ossez/codebank/interview/tests/others/LambdaEvensTest.java new file mode 100644 index 0000000000..3b872b063d --- /dev/null +++ b/src/test/java/com/ossez/codebank/interview/tests/others/LambdaEvensTest.java @@ -0,0 +1,49 @@ +package com.ossez.codebank.interview.tests.others; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * For Lambda Evens + * + * @author YuCheng + */ +public class LambdaEvensTest { + + private final static Logger logger = LoggerFactory.getLogger(LambdaEvensTest.class); + + /** + * Lambda Function + */ + + interface Arithmetic { + Long operation(Long a, Long b); + } + + + /** + * https://www.cwiki.us/display/ITCLASSIFICATION/Build+Castles + */ + @Test + public void testLambdaEvents() { + + String line = "1 2 3 4 5 6 "; + + String[] lineArray = line.split(" "); + List numbers = new ArrayList<>(); + Arithmetic division = (Long a, Long b) -> (a % b); + + + for (String lineChar : lineArray) { + if (division.operation(Long.parseLong(lineChar), 2L) == 0) { + System.out.print(lineChar + " "); +// logger.debug(lineChar + " "); + } + } + + } +} \ No newline at end of file