Java套件- [英] Java Package with -

查看:87
本文介绍了Java套件-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何导入名为"poof-support"的软件包.

否,我无法更改软件包名称,我收到一个错误:."预期的 .给出错误的行是:

  import poof-support.exception; 

解决方案

您的软件包名称中不能包含-.因此,您需要更改名称.

java文档中的某些软件包命名约定

  • 使用小写形式编写软件包名称,以避免与类或接口的名称冲突.

  • 在某些情况下,互联网域名可能不是有效的软件包名称.如果域名中包含连字符或其他特殊字符,或者软件包名称以数字或其他字符开头的Java名称的开头字符是非法的,或者软件包名称包含保留的Java关键字,则可能会发生这种情况例如"int".在这种情况下,建议的约定是添加下划线.例如:

 不正确的名称|正确的名字---------------------------------------------------------hyphenated-name.example.org |org.example.hyphenated_nameexample.int |int_.example123name.example.com |com.example._123name 

检查此链接以了解软件包的命名约定./p>

How do I import a package named "poof-support" .

No, I can't change the package name, I'm getting an: error '.' expected . The line giving the error is:

import poof-support.exception ;

解决方案

You can't have - in your package name. So you will need to change the name.

Some Package Naming Conventions from java Documentation

  • Package names are written in all lower case to avoid conflict with the names of classes or interfaces.

  • 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. For example:

  incorrect names                | correct names
  ---------------------------------------------------------  
  hyphenated-name.example.org    | org.example.hyphenated_name
  example.int                    | int_.example
  123name.example.com            | com.example._123name

check this link for naming conventions of package.

这篇关于Java套件-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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