开发者

what should I make my package if my domain has a dash?

The convention for开发者_如何转开发 packages is your domain name. Dashes are sometimes not allowed in package names. So if your domain name has a dash what should you use?


The "official" convention in Java is to replace it with an underscore.

From (an older version of) the spec:

In some cases, the internet domain name may not be a valid package name. Here are some suggested conventions for dealing with these situations:

If the domain name contains a hyphen, or any other special character not allowed in an identifier (§3.8), convert it into an underscore. If any of the resulting package name components are keywords (§3.9) then append underscore to them. If any of the resulting package name components start with a digit, or any other character that is not allowed as an initial character of an identifier, have an underscore prefixed to the component.


Underscore is an option I've used before, but otherwise, just concatenate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜