Find the Lambda evens for giving string
This commit is contained in:
parent
d34c492adb
commit
b4d068c639
@ -14,36 +14,36 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class LambdaEvensTest {
|
public class LambdaEvensTest {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LambdaEvensTest.class);
|
private final static Logger logger = LoggerFactory.getLogger(LambdaEvensTest.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lambda Function
|
* Lambda Function
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface Arithmetic {
|
interface Arithmetic {
|
||||||
Long operation(Long a, Long b);
|
Long operation(Long a, Long b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://www.cwiki.us/display/ITCLASSIFICATION/Build+Castles
|
* https://www.cwiki.us/display/ITCLASSIFICATION/Lambda+Evens
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLambdaEvents() {
|
public void testLambdaEvents() {
|
||||||
|
|
||||||
String line = "1 2 3 4 5 6 ";
|
String line = "1 2 3 4 5 6 ";
|
||||||
|
|
||||||
String[] lineArray = line.split(" ");
|
String[] lineArray = line.split(" ");
|
||||||
List<Long> numbers = new ArrayList<>();
|
List<Long> numbers = new ArrayList<>();
|
||||||
Arithmetic division = (Long a, Long b) -> (a % b);
|
Arithmetic division = (Long a, Long b) -> (a % b);
|
||||||
|
|
||||||
|
|
||||||
for (String lineChar : lineArray) {
|
for (String lineChar : lineArray) {
|
||||||
if (division.operation(Long.parseLong(lineChar), 2L) == 0) {
|
if (division.operation(Long.parseLong(lineChar), 2L) == 0) {
|
||||||
System.out.print(lineChar + " ");
|
System.out.print(lineChar + " ");
|
||||||
// logger.debug(lineChar + " ");
|
// logger.debug(lineChar + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user