First thanks to the Wu Yi of Groovy in action Part 1, and thanks to the author, translator, and uploader of the groovy Starter Classic, as well as to the audience who uploaded the PDF, and finally thanks to Groovy's father James Strachan
This article is based on groovy 1.8.
======== Split Line started in 2014-12-1 ========
1,groovy Start Running
Groovy Definitions and Features:
is an agile dynamic language based on a Java virtual machine.
Built on the powerful Java language and added many features learned from languages such as Python,ruby and Smalltalk.
Provides Java developers with modern, most popular programming language features and low learning costs (almost 0).
Support DSL (Domain specific languages domain definition language) and other concise syntax to make your code easier to read and maintain.
Goovy has processing native types, object-oriented, and an ant DSL, making it very easy to create shell scripts.
The developer's efficiency is greatly improved by the reduction of Framework code when developing Web,gui, database or console programs.
Unit Tests and simulations (objects) are supported to simplify testing.
Seamlessly integrates all existing Java objects and class libraries.
Compile directly into Java bytecode, so you can use groovy anywhere you use Java.
For example, using the Groovy console, enter the following code to output all the file names (recursion) in the current directory:
Groovy-e "New File ('. '). Eachfilerecurse {println It} "//-e Direct execution
Compared to Java classes with the same functionality, efficiency is seen.
3 Ways to run Groovy:
- Groovysh: script command line REPL
- Groovyconsole: Open GUI interface, above is the script editing area, the lower part is output, run shortcut key CTRL + R
- Groovy: Execute script file with parameters
For example, execute the groovy script:
Fibonacci.groovycurrent = 1 Next = 1 10.times {//Loop 10 times Print current + ' Newcurrent = next next = next + cur Rent = newcurrent} println "
Groovy Fibonacci===>1 1 2 3 5 8 13 21 34 55
2, grammarBasis
#!/usr/bin/groovy/* Multiline Comment */def y = 1; assert y = = 1// single-line comment assert current line y.equal (1), non-reference
Groovy Learning Summary