Reputation: 3774
New to java and have a question related to packages.
I like to keep objects organized in namespaces and ran into a problem with enums that I cannot figure out.
Say I have a nested enum like this:
package Project;
public class Foo
{
public enum Bar { One, Two, Three };
}
I want to do something like this
package Project.Attributes;
public class Foo
{
public setBar( Project.Foo.Bar bar ) {}
}
But I am getting name conflicts and unknown package 'Foo' errors.
How can I achieve this?
Upvotes: 0
Views: 281
Reputation: 597124
You need to have a semicolon at the end of the first line. And use lowercase letters for package names
Upvotes: 2
Reputation: 80186
It should work after below corrections
One more suggestion is to use small case for package names.
package project;
public class Foo
{
public enum Bar {
One, Two, Three
};
}
package project.attributes;
public class Foo
{
public void setBar(project.Foo.Bar bar)
{
}
}
Upvotes: 3