javanamingspecificationsname-length

Max name length of variable or method in Java


Is there a max length for class/method/variable names in Java? the JLS doesn't seem to mention that. I know very long names are problematic anyway from code readability and maintainability perspective, but just out of curiosity is there a limitation (I guess class names might be limited by the file system maximal file name limitation).


Solution

  • JLS: An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter.

    Also found similar question (though it didn't appear in my initial search, or when I typed the question title which is weird): Maximum Method Name Length