Java中变量或方法的最大名称长度 [英] Max name length of variable or method in Java

查看:1115
本文介绍了Java中变量或方法的最大名称长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java中的类/方法/变量名称是否有最大长度? JLS似乎没有提到这一点。我知道很长的名字无论从代码可读性和可维护性的角度来看都是有问题的,但出于好奇是有限制的(我猜类名可能受到文件系统最大文件名限制的限制)。

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).

推荐答案

抱歉,实际上在JLS中找到了答案:
http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#40625
似乎标识符名称的长度不限。

Sorry, actually found the answer in the JLS: http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#40625 It seems that identifier names are of unlimited length.

还发现了类似的问题(虽然它没有出现在我的初始搜索中,或者当我输入问题标题时这很奇怪):最大方法名称长度

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

这篇关于Java中变量或方法的最大名称长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆