2020-12-30 学习学习

2022-07-25

2020-12-30 08:55

可以通过调用System.currentTimeMillis()返回当前时间

public class ShowCurrentTime {
    public static void main(String[] args){
        long totalMilliseconds = System.currentTimeMillis();

        long totalSeconds = totalMilliseconds / 1000;

        long currentSecond = totalSeconds % 60;

        long totalMinutes = totalSeconds / 60;

        long currentMinute = totalMinutes % 60;

        long totalHours = totalMinutes / 60;

        long currentHour = totalHours % 24;

        System.out.println("Current time is " + currentHour + " : "
        + currentMinute + " : " + currentSecond + " GMT ");

    }
}

 

增强赋值操作符

count = count + 1; 可以写成 count += 1;

增强赋值操作符在表达式中所有其他操作符计算完成后执行;

就像赋值操作符一样(=)一样,操作符(+=  -=  *=  /=  %=)既可以构成赋值语句,也可以构成赋值表达式。

例如,在下面的代码中,第一行的x+=2是一条语句,而在第2行中它就是一个表达式:

x += 2; // Statement

System.out.println(x += 2); // Expression

 

09:18

学习时长23分钟

 

本文地址:https://blog.csdn.net/wanshuai666/article/details/111941534

《2020-12-30 学习学习.doc》

下载本文的Word格式文档,以方便收藏与打印。