做公司网站都需要什么,建网站的价格,怎么给网站添加站点统计,wordpres做影视网站Math#xff1a;
代表的是数学#xff0c;是一个工具类#xff0c;里面提供的都是对数据进行操作的一些静态方法。 示例代码#xff1a;
package cn.ensourced1_math;public class MathTest {public static void main(String[] args) {// 目标#xff1a;了解Math类提供…
Math
代表的是数学是一个工具类里面提供的都是对数据进行操作的一些静态方法。 示例代码
package cn.ensourced1_math;public class MathTest {public static void main(String[] args) {// 目标了解Math类提供的常用方法// abs方法System.out.println(Math.abs(-11.2));System.out.println(Math.abs(123));System.out.println(Math.abs(-3.14));// ceil方法System.out.println(Math.ceil(4.0001)); // 5.0System.out.println(Math.ceil(4.0));// floor方法System.out.println(Math.floor(6.99)); // 6.0// round方法(四舍五入System.out.println(Math.round(4.32)); // 4// Max/MinSystem.out.println(Math.max(11.2, 20)); // 20.0System.out.println(Math.min(11.2, 20)); // 11.2// pow(a, b) 次方System.out.println(Math.pow(2, 3)); // 8.0// 取随机数System.out.println(Math.random());}
}
不要刻意去记忆如果忘记了可以过来查找的。 System:
System代表程序所在的系统也是一个工具类。 package cn.ensourced1_math;public class SystemTest {public static void main(String[] args) {// 目标了解下System类的常见方法// System.exit(0); // 非零表示异常终止// 获取系统时间long time System.currentTimeMillis(); // 1970年来的毫秒值System.out.println(time);}
} 我们正常拿这个时间来做什么呢
做代码的性能分析。 Runtime
代表程序所在的运行环境。
Runtime是一个单例类。 package cn.ensourced1_math;import java.io.IOException;public class RuntimeTest {public static void main(String[] args) throws IOException, InterruptedException {// Runtime类Runtime r Runtime.getRuntime();// 终止当前运行的虚拟机
// r.exit(0); // 非零表示异常终止// Java虚拟机可用的处理器数System.out.println(r.availableProcessors());// 内存总量System.out.println(r.totalMemory()/(1024 * 1024) MB);// 可用内存System.out.println(r.freeMemory()/1024.0/1024.0 MB);// 启动某个程序
// r.exec(C:\\Program Files (x86)\\XMind\\XMind.exe);Process p r.exec(C:\\Program Files\\Tencent\\QQNT\\QQ.exe); // 直接绝对路径Thread.sleep(5000);p.destroy();}
}