2

I have not troubles with renaming packages in idea, but... I have "example" package and I want to rename it to "enum", but Idea does not allow me to do that. When I create a new package "enum", it warns me, that I will not be able to create any java classes within. What is the problem???

1
  • Is your package in the sources root package? Commented Nov 27, 2014 at 10:40

1 Answer 1

4

You cannot rename the package to enum, because it is a reserved keyword in Java.

At the Oracle tutorial page "Naming a package" it says

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".

3
  • Good catch! Completely blanked on this one. +1 Commented Nov 27, 2014 at 10:51
  • Thanks a lot, I thought that it is not applied to packages! Commented Nov 27, 2014 at 11:03
  • I was a bit surprised myself :)
    – user3001
    Commented Nov 27, 2014 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.