Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

class name  RSS feed

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Is there any limit on the number of characters in a class name?
-Sainudheen
 
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no.
 
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know of any limit imposed by the JVM/Javac compiler. (That's not to say that there may not be one, that's jsut saying that I'm not aware of it...)
But since the JVM requires the .class files to be in files, you are limited by the length of the file name on the OS, which (I think) is somewhere in the hundreds of characters (255 maybe? I'm not sure what OSes support these days).
Not that that really matters; if your class names are longer than about 25 characters, you should be thinking about revising your naming scheme....
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OS do limit the size of file names.
You can read the section 3.8 Identifiers of JLS.
 
Sainudheen Mydeen
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joel and Pradeep
I am sure I will not go to that extreme to name my class. I am trying to figure out whether java maintain any restriction on this.
Thanks
-Sainudheen
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!