‘clear()’ method removes all the elements from list.
HelloWorld.groovy
numbers = [0, 1, 2, 3, 4, 5, 3, 2, 1, 10] println "numbers : $numbers" println 'Clearing all the elements from numbers' numbers.clear() println "numbers : $numbers"
Output
numbers : [0, 1, 2, 3, 4, 5, 3, 2, 1, 10]
Clearing all the elements from numbers
numbers : []
No comments:
Post a Comment