Busy. Please wait.

show password
Forgot Password?

Don't have an account?  Sign up 

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
We do not share your email address with others. It is only used to allow you to reset your password. For details read our Privacy Policy and Terms of Service.

Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.

Remove Ads
Don't know
remaining cards
To flip the current card, click it or press the Spacebar key.  To move the current card to one of the three colored boxes, click on the box.  You may also press the UP ARROW key to move the card to the "Know" box, the DOWN ARROW key to move the card to the "Don't know" box, or the RIGHT ARROW key to move the card to the Remaining box.  You may also click on the card displayed in any of the three boxes to bring that card back to the center.

Pass complete!

"Know" box contains:
Time elapsed:
restart all cards

Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how


Deck JAVA 8 ( Nashorn )

Acessando classes Java jjs> Packages.MyPackage [JavaPackage MyPackage] jjs> Packages.MyPackage.MyClass [JavaClass MyPackage.MyClass]
Criando objetos Java jjs> var HashMap = Java.type("java.util.HashMap") jjs> var mapDef = new HashMap() jjs> var map100 = new HashMap(100)
Usando Java Beans jjs> var Date = Java.type("java.util.Date") jjs> var date = new Date() jjs> date.year + 1900 2013 jjs> date.year = 2014 - 1900 114 jjs> date.year + 1900 2014
Criando um mecanismo de scrip Nashorn ScriptEngine engine = factory.getEngineByName("nashorn");
Trabalhando com números Java jjs> var intNum = 10 jjs> intNum.class class java.lang.Integer jjs> var dblNum = Number(intNum) jjs> dblNum.class class java.lang.Double
Extensão de classe em Java var Run = Java.type("java.lang.Runnable"); var MyRun = Java.extend(Run, { run: function() { print("Run in separate thread"); } }); var Thread = Java.type("java.lang.Thread"); var th = new Thread(new MyRun());
Habilitar extensões de script em shell(UNIX) jjs -scripting
Here Document $ jjs -scripting heredocs.js So... foo = bar and the current time is Thu Aug 01 2013 16:21:16 GMT+0200 (CEST) $
Shell invocations var lines = 'ls -lsa'.split("\n"); for each (var line in lines) { print("|> " + line); }
Nashorn interpreta as coleções Java como arrays jjs> var ArrayList = Java.type("java.util.ArrayList") jjs> var alist = new ArrayList() jjs> alist.add("a") true jjs> alist.add("b") true jjs> alist.add("c") true jjs> alist[1] b jjs> for each (var i in alist) print(i) a b c
Strings são interpretadas pelo Nashorn como objetos java.lang.String jjs> var a = "abc" jjs> a.class class java.lang.String jjs> var b = a + "def" jjs> b.class class jdk.nashorn.internal.runtime.ConsString jjs> var c = String(b) jjs> c.class class java.lang.String
Objetos Globais $ARG >> jjs -scripting -- arg1 arg2 arg3 jjs> $ARG arg1,arg2,arg3 jjs> $ARG[1] arg2
Objetos Globais $ENV jjs> $ENV.USER johndoe jjs> $ENV.PWD /foo/bar
Objetos Globais $EXEC() jjs> $EXEC("ls -l") total 0 drwxr-xr-x+ 1 johndoe staff 4096 Aug 18 11:03 dir -rwxrw-r-- 1 johndoe staff 168 Aug 19 17:44 file.txt jjs>
load()Essa função carrega e avalia um script de um caminho, URL, ou um objeto. jjs> load("/foo/bar/script.js") jjs> load("http://example.com/script.js")
A função Java.type pode ser usada para se obter referências precisas do tipo Java var LinkedList = Java.type( "java.util.LinkedList"); var primitiveInt = Java.type( "int"); var arrayOfInts = Java.type( "int[]");
Interpretar uma aplicação de script JavaFX com o Nashorn, usando o mando jjs com a opção -fx jjs -fx JavaFXscript.js
Funções function sqr(x) x * x; print(sqr(3));
Created by: marcelotmr