Created
May 12, 2021 07:35
-
-
Save gauravkukade/1c12a2e35d8803106d4cf2b0e11f6b18 to your computer and use it in GitHub Desktop.
In this groovy program we will check the datatype of an object using getClass() method. Check the logpost at https://coderolls.com/determine-a-datatype-in-groovy/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class java.util.ArrayList | |
class java.lang.String | |
java.lang.String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In this groovy program we will check the datatype of an object using getClass() method | |
//check blogpost https://coderolls.com/determine-a-datatype-in-groovy/ | |
def names = ['Gaurav', 'Shubham', 'Nayan', 'Sudeep']; | |
println names.getClass(); // prints 'class java.util.ArrayList' | |
def blogname = '''coderolls'''; | |
println blogname.getClass(); // prints 'class java.lang.String' | |
println blogname.getClass().name; // prints 'java.lang.String' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment