-
Notifications
You must be signed in to change notification settings - Fork 0
07.いろんな式(2)
domanthan edited this page Jun 22, 2020
·
1 revision
/**
*
*/
package lesson04;
import java.util.Calendar;
/**
* @author gridscale
*
*/
public class Lesson04 {
/**
* @param args
*/
public static void main(String[] args) {
// 名前と年齢を出力。
String nameandage = "名前:" + getMyName() + ", 年齢:" + getMyAge();
System.out.println(nameandage);
System.out.println("今日は" + getWeekDay() + "曜日です。");
}
/**
* 曜日を返すメソッド。
*
* 実行時の日の、日、月、火、水、木、金、土という曜日を返す。
*/
private static String getWeekDay() {
//
//
Calendar today = Calendar.getInstance();
String returnValue = "";
switch (today.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SUNDAY:
returnValue = "日";
break;
case Calendar.MONDAY:
returnValue = "月";
break;
case Calendar.TUESDAY:
return "火";
case Calendar.WEDNESDAY:
return "水";
case Calendar.THURSDAY:
return "木";
case Calendar.FRIDAY:
return "金";
case Calendar.SATURDAY:
return "土";
default: return "Nothing";
}
return returnValue;
// throw new RuntimeException("ありえないこと発生しました。");
}
private static String getMyName() {
return "Huang";
}
private static int getMyAge() {
return 2;
}
}