| Java | Groovy | |
| Access modifier (by default) | package | public |
| getters and setters | Need to provide for fields | Are automatically generated for class members |
| Utility methods | System.out.println | println |
| Support substitution | Can print dynamic content without string concatation
Println(“Hello $name !”)
|
|
| Specifying type definition | Instead use keyword def
Mandatory for methods, optional for method arguments |
|
| Using semicolons | Every statements end with semicolon | optional |
| main method | To make a class executable | Don’t need |
| Initializing String arrays, static arrays | Curly braces { “abc”, “dfg”} | Square brackets [“abc”, “dfg”] |
| autoboxing/unboxing/conversion of primitives | yes | No, everything is Object and uses only Objects |
| Inner static classes | yes | no |
| Anonymous classes | yes | no |