To camelCase or not to camel_case

有些话、适合烂在心里 提交于 2019-12-03 16:26:58

问题


What is the standard when coding in Java, when do you use camel case when do you use underscores etc.


回答1:


You stick with the Java Code Conventions.

What exactly the standard is doesn't matter - what matters is that everyone follows it, and you should too.




回答2:


ClassName

  • Renderer
  • HttpSession

methodName

  • applyTo()
  • run()

instanceVariable / localVariable

  • currentUser
  • threadList

CONSTANT_NAME

  • LOG
  • DEFAULT_CONTEXT

G (Generic Type Parameter)

  • T
  • E



回答3:


See Sun's Code Conventions for the Java(TM) Programming Language.



来源:https://stackoverflow.com/questions/2082729/to-camelcase-or-not-to-camel-case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!