Skip to content

Commit bf787ed

Browse files
committed
tested Java8 Features
0 parents  commit bf787ed

File tree

7 files changed

+96
-0
lines changed

7 files changed

+96
-0
lines changed

.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_131"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>NewFeatures</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.features.java8;
2+
3+
public class FunctionalInterfaceLamda{
4+
5+
public static void main(String[] args) {
6+
7+
InterFaceI iFace = (str) -> System.out.println(str + "--");
8+
9+
iFace.myDispaly("yes");
10+
iFace.myDispaly("its working");
11+
}
12+
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.features.java8;
2+
3+
@FunctionalInterface
4+
public interface InterFaceI {
5+
6+
public void myDispaly(String str);
7+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.features.java8;
2+
3+
import java.util.stream.Stream;
4+
5+
public class StreamTest {
6+
7+
public static void main(String[] args) {
8+
9+
Stream.of("d2", "a2", "b1", "b3", "c")
10+
.map(u -> u.toUpperCase())
11+
.filter(s -> {
12+
System.out.println("filter: " + s);
13+
return s.contains("A");
14+
})
15+
.forEach(s -> System.out.println("forEach: " + s));
16+
17+
}
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.features.java8;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.function.Consumer;
6+
7+
public class TestForEach {
8+
9+
public static void main(String[] args) {
10+
List<Integer> li = new ArrayList<>();
11+
12+
for(int i =0; i<10; i++){
13+
li.add(i);
14+
}
15+
16+
li.forEach(new Consumer<Integer>() {
17+
18+
@Override
19+
public void accept(Integer t) {
20+
System.out.println(t);
21+
22+
}
23+
24+
});
25+
26+
System.out.println("-----------------------------------");
27+
28+
for(Integer in : li){
29+
System.out.println(in);
30+
}
31+
32+
33+
}
34+
}

0 commit comments

Comments
 (0)