Skip to main content

Posts

Showing posts with the label types

Groovy types

Java is a statically typed language , which means we have to declare the type of a variable at compile time. Python is dynamically typed. which means that references can never to bound to types at compile time. Groovy on the other hand has optional typing. What this means is Groovy references can be statically typed like in Java, or dynamically typed like in Python. String staticStr = new String("this is a statically typed String"); staticStr = 8; println """The type of staticStr is: ${staticStr.class.getName()} """ println """It's value is: $staticStr""" The output form running the above program is: String staticStr = new String("this is a statically typed String"); staticStr = 8; println """The type of staticStr is: ${staticStr.class.getName()} """ println """It's value is: $staticStr""" As you can see, staticStr remains a string even a...