Learn Java for Web Development
399 Appendix B Introduction to Groovy Groovy is an agile and dynamic language for the Java Virtual Machine that builds upon the ...
400 APPENDIX B: Introduction to Groovy Note Groovy requires Java, so you need to have a version available (while Groovy 1.6 supp ...
APPENDIX B: Introduction to Groovy 401 Listing B-3. Groovy Script for “Hello World” println "Hello World!" You can run Groovy sc ...
402 APPENDIX B: Introduction to Groovy GroovyConsole GroovyConsole, shown in Figure B-3, is a graphical version of GroovyShell. ...
APPENDIX B: Introduction to Groovy 403 Figure B-4 shows GroovyConsole with the output detached. You can start GroovyConsole in a ...
404 APPENDIX B: Introduction to Groovy The console provides the ability to create, save, load, and execute classes and scripts. ...
APPENDIX B: Introduction to Groovy 405 GStrings GStrings are an instance of groovy.lang.GString and allow placeholders to be inc ...
406 APPENDIX B: Introduction to Groovy Listing B-8. Nested Double Quote in Single Quote s1 = 'hello "vishal"' println s1 Strings ...
APPENDIX B: Introduction to Groovy 407 Slashy Strings As mentioned earlier, slashes can be used to define strings. The slashy no ...
408 APPENDIX B: Introduction to Groovy Line 4 has an expression, $name, that is evaluated to vishal, as shown in the output. ...
APPENDIX B: Introduction to Groovy 409 This time Groovy does not interpret $ test in line 6 as an expression because there is an ...
410 APPENDIX B: Introduction to Groovy Arrays A Groovy array is a sequence of objects, just like a Java array (see Listing B-17) ...
APPENDIX B: Introduction to Groovy 411 On line 1, an empty list is created by assigning a property the value of []. Lin ...
412 APPENDIX B: Introduction to Groovy Line 1 illustrates how to define a map with multiple entries. When using the square b ...
APPENDIX B: Introduction to Groovy 413 Listing B-20. Creating and Using Ranges def numRange = 0..9 numRange.each {print it} pri ...
414 APPENDIX B: Introduction to Groovy Sets A Groovy set is an unordered collection of objects, with no duplicates, just as in J ...
APPENDIX B: Introduction to Groovy 415 The return type and the return statement are not included in the body of the method. ...
416 APPENDIX B: Introduction to Groovy Listing B-25. Calling a Closure def closureVar = {println 'Hello world'} println "closur ...
APPENDIX B: Introduction to Groovy 417 Here is the output: Hello world Hello default world Closures always have a return value. ...
418 APPENDIX B: Introduction to Groovy A closure always has at least one argument, which will be available within the body of th ...
«
15
16
17
18
19
20
21
22
23
24
»
Free download pdf