gpt4 book ai didi

java - 枚举返回语句

转载 作者:行者123 更新时间:2023-12-01 13:16:49 25 4
gpt4 key购买 nike

如果我有一个接口(interface),并且该接口(interface)内部有一个返回类型枚举器的方法,那么在实现该接口(interface)的类中我应该如何编写 return 语句?喜欢:

public enum Day 
{
Saturday,Sunday....
}

public interface blabla
{
public Day getDay();
}

public class blabla2 implements blabla
{
public Day getDay()
{
return ???? what should I write here ?
}
}

最佳答案

return ???? what should I write here ?

嗯,这取决于你如何确定返回日期,但如果日期是固定的,你可以写

public Day getDay() 
{
return Sunday; //or Day.Sunday depending on your imports and package
}

关于java - 枚举返回语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22408300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com