Groovy web console

subscribe to the feed Subscribe
to this
site

01 Data Types

Published 2 months ago by ST with tags groovy
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
//Literals and data types

12 //integer
1.45 // floating-point integer
true // (or false) boolean
'Hello' // string
null // void/undefined object reference

newDate() // instances of other Java or Groovy classes (see e.g. API documentation)
          // https://docs.oracle.com/javase/8/docs/api/java/util/Date.html

// Declaring variables

// untyped
def str1 = 'Hello'
// or typed
String str2 = 'World'

println(str1 + ' ' + str2)

// an uninitialized variable is null (unless it is typed as a primitive)
def none
println(none)