Skip to content

Commit fd0319a

Browse files
committed
Streams
Streams
1 parent e4d035f commit fd0319a

File tree

7 files changed

+617
-168
lines changed

7 files changed

+617
-168
lines changed

nbproject/build-impl.xml

Lines changed: 511 additions & 164 deletions
Large diffs are not rendered by default.

nbproject/genfiles.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
build.xml.data.CRC32=53a7d579
22
build.xml.script.CRC32=c6b5575f
3-
build.xml.stylesheet.CRC32=8064a381@1.79.1.48
3+
build.xml.stylesheet.CRC32=f85dc8f2@1.90.1.48
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
66
nbproject/build-impl.xml.data.CRC32=53a7d579
7-
nbproject/build-impl.xml.script.CRC32=3066fa53
8-
nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
7+
nbproject/build-impl.xml.script.CRC32=f390ffbe
8+
nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.90.1.48

nbproject/private/private.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ do.depend=false
33
do.jar=true
44
javac.debug=true
55
javadoc.preview=true
6-
user.properties.file=C:\\Users\\manbhakr\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
6+
user.properties.file=C:\\Users\\manbhakr\\AppData\\Roaming\\NetBeans\\10.0\\build.properties

nbproject/project.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ build.test.results.dir=${build.dir}/test/results
1919
#debug.transport=dt_socket
2020
debug.classpath=\
2121
${run.classpath}
22+
debug.modulepath=\
23+
${run.modulepath}
2224
debug.test.classpath=\
2325
${run.test.classpath}
26+
debug.test.modulepath=\
27+
${run.test.modulepath}
2428
# Files in build.classes.dir which should be excluded from distribution jar
2529
dist.archive.excludes=
2630
# This directory is removed when the project is cleaned:
@@ -36,13 +40,17 @@ javac.classpath=
3640
javac.compilerargs=
3741
javac.deprecation=false
3842
javac.external.vm=true
43+
javac.modulepath=
44+
javac.processormodulepath=
3945
javac.processorpath=\
4046
${javac.classpath}
4147
javac.source=1.8
4248
javac.target=1.8
4349
javac.test.classpath=\
4450
${javac.classpath}:\
4551
${build.classes.dir}
52+
javac.test.modulepath=\
53+
${javac.modulepath}
4654
javac.test.processorpath=\
4755
${javac.test.classpath}
4856
javadoc.additionalparam=
@@ -68,9 +76,13 @@ run.classpath=\
6876
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
6977
# To set system properties for unit tests define test-sys-prop.name=value:
7078
run.jvmargs=
79+
run.modulepath=\
80+
${javac.modulepath}
7181
run.test.classpath=\
7282
${javac.test.classpath}:\
7383
${build.test.classes.dir}
84+
run.test.modulepath=\
85+
${javac.test.modulepath}
7486
source.encoding=UTF-8
7587
src.dir=src
7688
test.src.dir=test
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.know.streams;
2+
3+
import com.know.util.DataUtil;
4+
import com.know.util.Utility;
5+
import java.util.List;
6+
import java.util.stream.Collectors;
7+
8+
/**
9+
* Steam configuration can be done by filter and map operation
10+
* @author KnowGroup
11+
*/
12+
public class Lesson_01_Stream_Configuration_filter_map {
13+
14+
public static void main(String[] arg){
15+
/*
16+
filter | elements based on a given predicate
17+
*/
18+
List<Integer> collect =
19+
DataUtil.fibbinacos().stream().filter(n->n%2==0).collect(Collectors.toList());
20+
collect.stream().forEach(System.out::println);
21+
22+
Utility.log("============");
23+
24+
/*
25+
map | elements to another form defined in a function
26+
*/
27+
List<Integer> mapped =
28+
DataUtil.fibbinacos().stream().map(n->n*n).collect(Collectors.toList());
29+
mapped.stream().forEach(System.out::println);
30+
}
31+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.know.streams;
2+
3+
import com.know.util.DataUtil;
4+
import static com.know.util.DataUtil.*;
5+
import static com.know.util.Utility.*;
6+
import java.util.Set;
7+
import java.util.stream.Collectors;
8+
9+
/**
10+
*
11+
* @author KnowGroup
12+
*/
13+
public class Lesson_02_Stream_Processing {
14+
15+
public static void main(String[] arg){
16+
17+
/*
18+
collect | element to a give Collector
19+
*/
20+
//log(otp());
21+
Set<Integer> collect = DataUtil.fibbinacos().stream().collect(Collectors.toSet());
22+
23+
}
24+
}

src/com/know/util/DataUtil.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.know.util;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
*
8+
* @author KnowGroup
9+
*/
10+
public class DataUtil {
11+
12+
public static List<Integer> fibbinacos(){
13+
List<Integer> result = new ArrayList<>();
14+
result.add(1);
15+
result.add(2);
16+
result.add(3);
17+
result.add(5);
18+
result.add(8);
19+
result.add(13);
20+
result.add(21);
21+
result.add(34);
22+
result.add(55);
23+
result.add(89);
24+
result.add(134);
25+
return result;
26+
}
27+
28+
public static String otp(){
29+
final StringBuilder o = new StringBuilder();
30+
for(int i = 0 ; i < 6 ;i++){
31+
o.append((int)(Math.random()*10));
32+
}
33+
return o.toString();
34+
}
35+
}

0 commit comments

Comments
 (0)