I was wondering : is there a maximum in the length of the method names ? Or more precisely : is ther a maxiumum in the significant number of characters in a name ? Like : getThis and getThat are both allowed, but because the JVM only looks at the first 5 characters, both names are equal.
I think the only limitation is that the method name will be stored in the class file as a CONSTANT_Utf8_info structure, which uses an unsigned two-byte integer to represent the number of bytes in the String data. This limits the length of a method name to around 65536 characters. I'd be very impressed -- or horrified -- if anyone had hit this limitation in real life!
It is 65535 characters to be exact. The same rule applies to the length of the class level variables as well (but not to the local variables - the one which is defined inside a method). Hope you can figure out why.
just to be sure : although the length is almost unlimited, does the compiler/jvm use every character. It's just that I know in C, a functionname can have almost any length, but only the first, say, 14 characters are actually used.
That was a limitation of old-fashioned linkers, generally not a compiler or a language itself. It's not really a problem anymore -- C++'s long mangled names forced linker developers to accomodate arbitrarily long external symbols.
In any case, Java doesn't use the platform linker to link its classes, so no such limitation applies. The answer is yes, every character counts.
You probably missed that our naming policy requires everyone to use a full last name. Please adjust your display name accordingly. Thanks!
Regarding your question, I'm quite sure that Java uses the full name to differentiate between identifiers, no matter how long they are.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus