Data types
The first thing you learn about any programming language are the data types; how any programming language stores the data. Similar to the other programming languages, Groovy also offers a different set of data types for numerical, strings, char, and so on. As compared to Java, there are no primitive types present in Groovy. Groovy treats everything as an object, which makes Groovy a pure Object Oriented language. The problem with primitive data types is that developers can't perform any object-level operations, such as calling methods on them. Also, you can't store them as an object in maps and sets (collections that require objects). The following table shows primitive data types and wrapper types with default values:
Data type |
---|
Get Mastering Gradle now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.