Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maximum Length for a Variable Name.

 
Udegbunam Morah
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, can someone help me with the maximum possible length for a variable name.

Thanks for your patience and understanding.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No idea. Why don't you just keep typing and see if you hit any problems?
 
Nick Stevens
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is a limit for variable name length, but if you
make the variable names too long then your code will run slower :-)
 
FELIX ALE
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Variable names can be upto 32 digits.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
32 digits ???
Do you mean length of the variable is restricted to 32 . No even this works
private int abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz = 78;
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the length of a variable name can be a 32 bit integer number. Which number is the maximum the compiler will allow is open to experimentation.
Anyone wanting to try a variable name of 65000 characters is hereby invited to try
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeroen Wenting:
Anyone wanting to try a variable name of 65000 characters is hereby invited to try


I'll take that challenge

65535 - A-OK!
65536 - Oh no! UTF8 representation for string "aaaaaaaaaaaaaaaaaaaa..." is too long for the constant pool
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I tried an int. Got to 2097088 characters in the variable name before the compiler ran out of memory (I was doubling its length from 65535 each time so you may well be able to create a bigger one). I'm so glad I know that now...
[ April 08, 2005: Message edited by: Paul Sturrock ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic