4, different from Java
(1) Universal
l In Groovy, == Equivalent to equals (), === means identification comparison (equivalent to java ==)
l In Java == means the equalization of the original type and the identity of the object, such as A == B (A and B are referenced to the same object)
l Communicate closure to methods or use Groovymarkup, {should be called on the same line, such as:
[1, 2, 3]. Each {println it}
l If you want to put {on a row independent of the method, use parentheses ()
[1, 2, 3]. Each
{PrintLn it}
)
l The following is invalid, explain the closure into a separate closure without passing the closure as a method of passing
[1, 2, 3] .each
{
Println IT
}
(2) Things that should be realized
l The semicolon behind the statement is optional, but there are multiple statements in the same line to separate sequel.
l return keyword optional
l can be used within the Static method _this_ keyword (what is it?)
l Default modifiers are public
l Groovy Protected and Java's protected and java protected
l Supplement: When the method is called, parentheses are optional.
(3) Groovy new features in Java
l Close
L List and local grammar for MAP
l Groovymarkup and GPath support
l Regular expression local support
l Multi-form ITERATION and powerful Switch statements
l Support for dynamic and static types
l Embed an expression in a string
l Add many new help methods
l Simplify the syntax of the BEAN in terms of attribute and add event listening.