如下为代码,具体哪里错了啊???
/*
输入数字显示日期
*/
import java.util.Scanner;
class Demo1
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("请输入数字1~7");
int value = sc.nextInt();
String week = getWeek(value);
System.out.println(week);
}
public static String getWeek(int value){
String[] arr = {" ","一","二","三","四","五","六","日"};
for(int i=0;i<arr.length;i++){
if(i == value){
return arr[i];
}
}
return "不存在";
}
}
|
|