Book Image

Mastering Gradle

Book Image

Mastering Gradle

Overview of this book

Table of Contents (17 chapters)
Mastering Gradle
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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

Wrapper type

Default values

byte

Byte

0

short

Short

0

int

Integer

0

long

Long

0L

float

Float

0.0f

double

Double

0.0d

char

Character

\u0000

boolean

Boolean

false

String

Not Applicable

null

Groovy gives you the flexibility to...