用数字0-6表示星期
发布网友
发布时间:2023-08-09 07:07
我来回答
共3个回答
热心网友
时间:2023-10-02 20:06
public class week
{
public static void main(String[] args)
{
int i=Integer.parseInt(args[0]);
switch(i)
{
case(0):System.out.println("星期日");break;
case(1):System.out.println("星期一");break;
......
}
}
}
热心网友
时间:2023-10-02 20:06
public interface WEEK {
public static final int SUNDAY = 0;
public static final int MONDAY = 1;
...
public static final int SATURDAY = 6;
}
people might prefer "enum", which was introced in Java5:
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
}
热心网友
时间:2023-10-02 20:06
用多分支语句switch case;就可以了