2
votes

I have an app in grails which uses list contained in a map. I am using the list for simple string comparison in my code (value[0]=="something" for example). the println showed the value[0] to be "something" but the test always failed. On further checking the class for value[0] [through value[0].getClass() ], I found the class of type [C. Anybody has any clue on this. The list is stored in a map and I am doing a map.each to get to the list (if that makes a difference). Here is my code and println output in my console.

code

println "it.value[0] = " + it.value[0]
println "it.value[1] = " + it.value[1]
println "it.value[2] = " + it.value[2]

println "it.value[0] class = "+ it.value[0].getClass()
println "it.value[1] class = "+ it.value[1].getClass()
println "it.value[2] class = "+ it.value[2].getClass()

output

it.value[0] = abc
it.value[1] = def
it.value[2] = ghi

it.value[0] class = class [C
it.value[1] class = class [C
it.value[2] class = class [C
1

1 Answers

5
votes

[C is the Java field descriptor for a primitive character array (char[]). These get shown when you examine the class name of an array type.

assert ("foo" as char[]).getClass().toString() == 'class [C'

The rules for how they get built are in the JVM Specification section on Field Descriptors.