什么是开头编号的包名称的规则? [英] What is the rule of the name of the packages that start with number?
问题描述
在Android上的包命名约定是:
The package naming convention in Android is:
com.organizationName.appName
但是,如果单位名称或的appName开始以数字或下划线,就变成了无效的名称,因为Android不接受,开始与一些字或下划线。
But if the organizationName or the appName starts with a number or underscore, it becomes a invalid name, since android doesn't accept words that start with number or underscore.
例如:
com.1organizationName.appName
是无效的。
什么是重命名这个包中的约定?
What is the convention to rename this package?
推荐答案
在官方命名一包 Java文档,它具有以下语句:
In the official "Naming a Package" java documentation, it has the following statement:
在某些情况下,互联网域名可能不是一个有效的软件包 名称。这可能发生,如果域名包含连字符或其他 特殊字符,如果包名以数字开头或其他 字符是非法的,作为一个Java名称的开头使用或 如果包名的包含一个保留的Java关键字,比如INT。 在这种情况下,在的建议的惯例是添加下划线的
In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore.
所以,你的情况,这将是 com._1organizationname.appname
So in your case, it would be com._1organizationname.appname
编辑:刚刚发现这个在的Android文档:
Just found this in the Android docs:
应用程序的完整的Java语言风格的包名。名字 应该是唯一的。该名称可以包含大写或小写字母 (A到Z),数字和下划线(_)。 然而,个别 包名称部件只能先从字母。
A full Java-language-style package name for the application. The name should be unique. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters.
因此很明显,这是的没有的相当Java风格。不幸的是,它看起来像在这种情况下,你最好的选择将实际上是拼出来的数字,如: com.oneorganizationname.appname
。
So apparently it's not quite Java-style. Unfortunately, it looks like your best bet in this case would in fact be to spell out the number, e.g. com.oneorganizationname.appname
.
这篇关于什么是开头编号的包名称的规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!