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

Commitca52506

Browse files
committed
nashorn samples
1 parentebe8ada commitca52506

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎res/nashorn2.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ var Nashorn2 = Java.type('com.winterbe.java8.Nashorn2');
22
varresult=Nashorn2.fun('John Doe');
33
print('\n'+result);
44

5+
Nashorn2.fun2(123);
6+
Nashorn2.fun2(49.99);
7+
Nashorn2.fun2(true);
8+
Nashorn2.fun2("hi there")
9+
Nashorn2.fun2(String("bam"))
10+
Nashorn2.fun2(newNumber(23));
511
Nashorn2.fun2(newDate());
612
Nashorn2.fun2(newRegExp());
713
Nashorn2.fun2({foo:'bar'});

‎src/com/winterbe/java8/Nashorn1.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static void main(String[] args) throws Exception {
2121
Invocableinvocable = (Invocable)engine;
2222
Objectresult =invocable.invokeFunction("fun1","Peter Parker");
2323
System.out.println(result);
24+
System.out.println(result.getClass());
2425

2526
invocable.invokeFunction("fun2",newDate());
2627
invocable.invokeFunction("fun2",LocalDateTime.now());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp