When I try to create a package implements
using Intellij (community edition) I got message Not a valid package name
. Is this because of the keyword being used?
When I try to create a package implements
using Intellij (community edition) I got message Not a valid package name
. Is this because of the keyword being used?
Is this because of the keyword being used?
Yes, a package name has the following form
PackageDeclaration:
{PackageModifier} package Identifier {. Identifier} ;
where Identifier
is
Identifier:
IdentifierChars but not a Keyword or BooleanLiteral or NullLiteral
IdentifierChars:
JavaLetter {JavaLetterOrDigit}
JavaLetter:
any Unicode character that is a "Java letter"
JavaLetterOrDigit:
any Unicode character that is a "Java letter-or-digit"
So keywords cannot be used.
You can not use a java keyword in your package declaration.
abstract continue for new switch
assert default if package synchronized
boolean do goto private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while
These keyworkds can not be used.
the syntax of package declaration is
PackageDeclaration:
{PackageModifier} package Identifier {. Identifier} ;
Here Identifiers are any Unicode character that is a "Java letter" or any Unicode character that is a "Java letter-or-digit".
The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024). The $ sign should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.
Refer
You cannot use a Java keyword as package name. See JLS on Names and Identifiers
This works fine for me, in Intellij 13.1.2, however, you can't use a package with this name even if you create one, because the java package
statement won't accept a keyword anywhere in the package names. So, I can create, but can't use:
package com.implements.thing;