Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit423b9d3

Browse files
committed
using collection streams from javascript with nashorn
1 parent56c19d7 commit423b9d3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎res/nashorn3.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,41 @@ list.add('b');
4848
list.add('c');
4949

5050
foreach(varelinlist)print(el);
51+
52+
53+
print('------------------');
54+
print('HashMap:');
55+
56+
varHashMap=Java.type('java.util.HashMap');
57+
58+
varmap=newHashMap();
59+
map.put('foo','foo1');
60+
map.put('bar','bar1');
61+
62+
foreach(vareinmap.keySet())print(e);
63+
64+
foreach(vareinmap.values())print(e);
65+
66+
67+
print('------------------');
68+
print('Streams:');
69+
70+
varlist2=newArrayList();
71+
list2.add("ddd2");
72+
list2.add("aaa2");
73+
list2.add("bbb1");
74+
list2.add("aaa1");
75+
list2.add("bbb3");
76+
list2.add("ccc");
77+
list2.add("bbb2");
78+
list2.add("ddd1");
79+
80+
list2
81+
.stream()
82+
.filter(function(el){
83+
returnel.startsWith("aaa");
84+
})
85+
.sorted()
86+
.forEach(function(el){
87+
print(el);
88+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp