Wednesday, 30 January 2019

Groovy: Get the package name of a class


'package' keyword is used to get the package name of a class.

Example
String.'package'.name

Above statement returns the package name of String class.

HelloWorld.groovy
String packageName = String.'package'.name

println packageName



Previous                                                 Next                                                 Home

No comments:

Post a Comment