【笔记02】

hwwjian

关注

阅读 67

2022-01-04

short s1 = 1; s1 = s1 + 1; (s1+1运算结果是int型,需要强制转换类型)

short s1 = 1; s1 += 1;(可以正确编译)

public class Test {

         public static void main(String[] args) {

                  int week = 2;

                  week += 100;

                  week = week % 7;

                  System.out.println("100天后星期" + week);

         }

}
public class TestExer1 {
	public static void main(String[] args) {
		int hour = 89;
		int day = hour / 24;
		hour = hour % 24;
		System.out.println("为抵抗洪水,战士连续作战" + day + "天" + hour + "小时");
	}
}
public static void main(String[] args) {
		char x = 'x';
		int i = 10;
		System.out.println(true? x : i);
		System.out.println(true? 'x' : 10);
	}

精彩评论(0)

0 0 举报