java中enum参数怎么赋值
答案:1 悬赏:40 手机版
解决时间 2021-11-15 03:04
- 提问者网友:萌卜娃娃
- 2021-11-14 14:14
java中enum参数怎么赋值
最佳答案
- 五星知识达人网友:像个废品
- 2021-11-14 15:03
public class MainClass {
enum Day {
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}
public static void main(String[] args) {
Day yesterday = Day.Tuesday;
Day today = Day.Wednesday;
Day tomorrow = Day.Thursday;
print(yesterday,today,tomorrow);
}
static void print(Day yesterday,Day today,Day tomorrow){
System.out.println("Today is " + today);
System.out.println("Tomorrow will be " + tomorrow);
System.out.println("Yesterday was " + yesterday);
}
}
enum Day {
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}
public static void main(String[] args) {
Day yesterday = Day.Tuesday;
Day today = Day.Wednesday;
Day tomorrow = Day.Thursday;
print(yesterday,today,tomorrow);
}
static void print(Day yesterday,Day today,Day tomorrow){
System.out.println("Today is " + today);
System.out.println("Tomorrow will be " + tomorrow);
System.out.println("Yesterday was " + yesterday);
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯