Skip to content

Commit 57c2512

Browse files
committed
Add NumberStartWithOne class to filter numbers starting with '1' from a list
1 parent 64f6968 commit 57c2512

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.java8;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
public class NumberStartWithOne {
7+
public static void main(String[] args) {
8+
List<Integer> numberList = Arrays.asList(1, 2, 3, 4, 5, 11, 17, 19);
9+
List<String> startWitOneList = numberList.
10+
stream().map(x -> x + ""). //Convert a List to Integer.
11+
filter(x -> x.startsWith("1")).toList();
12+
System.out.println(startWitOneList);
13+
}
14+
}

0 commit comments

Comments
 (0)