使用Java RMI时是否有约定在变量名中使用美元符号$? [英] Is there a convention, when using Java RMI, to use the dollar sign $ in a variable name?

查看:137
本文介绍了使用Java RMI时是否有约定在变量名中使用美元符号$?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到它是变量名的有效部分,但我从未见过变量名之前曾实际使用符号$.

I realize that it is a valid part of a variable name, but I've never seen variable names actually use the symbol $ before.

Java教程说:

此外,按照惯例,美元符号字符根本不会使用.您可能会发现在某些情况下,自动生成的名称将包含美元符号,但您的变量名称应始终避免使用它.

Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it.

但是,由于这是针对Java初学者的,所以我想知道在分布式世界中,$是否具有特殊含义.

However, since this is geared toward Java beginners, I'm wondering if in the distributed world, the $ lives on with a special meaning.

推荐答案

我唯一见过的是

  • 在生成的代理类中,它们经常在其方法,变量和类名中使用$
  • 内部->外部类综合访问器方法,我认为在方法名称中也使用$
  • 内部类名称(如JVM所见)
  • in generated proxy classes, which frequently use $ in their method, variable and class names
  • inner->outer class synthetic accessor methods, which I think also use a $ in the method name
  • inner class names (as seen by the JVM)

不过,我从未见过它在源代码中使用过,而且我也没有想到这样做的任何原因. $几乎是所生成代码的明确指示.

I've never seen it used in source code, though, and I can't think of any reason for doing so. The $ is almost a definitive indicator of generated code.

这篇关于使用Java RMI时是否有约定在变量名中使用美元符号$?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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