Java中的枚举enum
我无法理解一个问题。问题是: 编写一条语句,使Terms枚举中的常量无需限定即可可供类使用
这是我到目前为止的代码;
public enum Terms {
NET_30_DAYS, NET_60_DAYS, NET_90_DAYS;
//either name() or super() can be used
@Override
public String toString() {
String s = "Net due " + name() + " days";
return s;
}
}
I'm having trouble understanding a question. The question is:
Code a statement that will make the constants in the Terms enumeration available to a class without qualification
This is my code so far;
public enum Terms {
NET_30_DAYS, NET_60_DAYS, NET_90_DAYS;
//either name() or super() can be used
@Override
public String toString() {
String s = "Net due " + name() + " days";
return s;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为他们指的是 静态导入。
示例:
这将使您能够使用如下代码:
I think that they refer to static import.
Example:
This will enable you to use your code like:
您可能正在寻找
这里有一点需要注意。如果您的Terms.java位于默认包中,则无法对其进行静态导入。
You're probably looking for
There is one thing to note here. If your Terms.java is in a default package, there is not a way to do a static import on it.