Apache groovy considered being an object oriented programming language. This is used for the java platform. It is static as well as dynamic language. This Groovy has characteristics similar to python, Ruby, perl and smalltalk. This groovy will be used for programming language and scripting language for the java platform.
Groovy is having many features like DSL support, closures and also dynamic typing. Like all other programming language, groovy cannot replacement for java. The source code of groovy will not be a replacement for java. The source code of groovy complies in java Bytecode, so that will be run on any platform where JRE is installed.
Apache Groovy has following features
- It has support for both static and dynamic typing
- It has support for operator overloading
- It is native syntax for lists and associative arrays.
- It is native support for regular expressions
- It has native support for various markup language such as XML andHTML.
- Groovy is very simple for Java developers. Java and Groovy are similar
- We can extend Java libraries.
- Groovy also extends the java.lang.object.
Why Apache Groovy is used for?
Apache groovy, is robust typed and dynamic language, with static-typing and static compilation capabilities java platforms has goal at improving developer productivity. It combines smoothly with any java program and in no time delivers to our application powerful features, including scripting capabilities.
- Flat learning curve-it is concise readable and expressive syntax and also easy to learn for java developers.
- It has good integration with Java- Integrates and interoperates well with java and any third party libraries.
- It is vibrant and very rich ecosystem-webdevelopment, reactive applications, concurrency/asynchronous/parallelism library, test framework build tools, code analysis GUI building.
- Powerful features-There are closures,constructors, runtime and compile time meta programming and and also functional programming languages exists.
- Domain specific language-
- Scripting and testing glue-There is a writing maintainable tests all entire our build and automation tasks.
How to install Groovy
step 1 –Ensure that you have installed java .
Step 2- we should type http://groovy-lang.org/download.html and click installer.
step 3-Launch the downloaded installer. Select the language and click Ok.
step 4-Launch the welcome screen,click Next.
Step 5-Agree the licence terms.
step 6-select the components we want to install click next.
Step 7-select installation directory and click next.
step 8- choose the Start Menu Folder and click Next.
Step 9-When installation is done click next.
step 10-Click next and select start menu.
Range
A range can be a shorthand for mainly telling a sequence of values.A range is denoted by the first and last values in sequence and Range will be inclusive or may be exclusive.A inclusive range will include all the values from the first to the last while an exclusive range includes all the values except the last.There are some examples of range literals
1…10-An example of an inclusive range
1….<10-An example of an exclusive range
‘a’….’x’-Ranges that can consists of characters
10….1-Ranges can also be in a descending order.
There are many methods
1. Contains- It will check if a range has specific values.
2. Get
It returns the element at the specified position in this range.
3.getForm
It get the lower value of range
4.Goto
It will get the upper value of this range
5. isReverse
Is this a reverse range iterating backwards.
6.size
Returns the number of elements in this range.
7.subList
Returns a view of the portion of this range between the specified fromindex inclusive,andtolindex,exclusive.
Traits
Traits are the structural construct of the language that will allow
the composition of behaviors
Runtime implementation of interfaces
Compatibility with static type checking/compilation
Questions
1.What is Apache groovy?
2. Why Apache groovy is used?