以 java. 开头的是什么包,什么是开头编号的包名称的规则?

The package naming convention in Android is:

com.organizationName.appName

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.

For example:

com.1organizationName.appName is invalid

What is the convention to rename this package?

解决方案

In the official "Naming a Package" java documentation, it has the following statement:

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.

So in your case, it would be com._1organizationname.appname

EDIT: Just found this in the Android docs:

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.

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值