logo image

How to change a List of Strings from Lower Case to Upper Case in Groovy



Following is the Groovy program which iterates on a List of Strings and change the case of all elements from Lower Case to Upper Case

class GroovyChangeCaseOfListEmenets {
	static void main(String[] args) {

		def colours = [ 'red', 'green', 'blue' ]
		
		def newList = colours.collect{ it.toUpperCase() }
		
		print newList
	}
}

Output

[RED, GREEN, BLUE]