您的位置:首页 > 教育 > 培训 > 室内设计师培训班多少钱_小米网络营销案例分析_如何创建自己的卡网_网络营销与传统营销的整合

室内设计师培训班多少钱_小米网络营销案例分析_如何创建自己的卡网_网络营销与传统营销的整合

2025/2/26 7:01:37 来源:https://blog.csdn.net/zeijiershuai/article/details/144546794  浏览:    关键词:室内设计师培训班多少钱_小米网络营销案例分析_如何创建自己的卡网_网络营销与传统营销的整合
室内设计师培训班多少钱_小米网络营销案例分析_如何创建自己的卡网_网络营销与传统营销的整合

1. Math

        (1) 代表数学,是一个工具类,里面提供的都是对数据操作的一些静态方法。

        (2) Math 类常见的方法:

方法说明
public static int abs(int a)获取参数的绝对值(其他基本类型方法相同)
public static double ceil(double a)向上取整
public static double floor(double a)向下取整
public static int round(float a)四舍五入
public static int max(int a, int b)获取两个int值中的较大值(其他基本类型方法相同)
public static double pow(double a, double b)返回a的b次幂的值
public static double random()返回double 类型的随机值范围[0.0,1.0]
public static void main(String[] args) {//public static int abs(int a)	获取参数的绝对值(其他基本类型方法相同)System.out.println(Math.abs(-123));//123System.out.println(Math.abs(123));//123System.out.println(Math.abs(123.03));//123.03System.out.println(Math.abs(-123.03));//123.03//public static double ceil(double a)	向上取整System.out.println(Math.ceil(123.03));//124.0System.out.println(Math.ceil(123.00));//123.0//public static double floor(double a)	向下取整System.out.println(Math.floor(123.06));//123.0System.out.println(Math.floor(123.00));//123.0//public static int round(float a)	四舍五入System.out.println(Math.round(123.606));//124System.out.println(Math.round(123.404));//123//public static int max(int a, int b)	获取两个int值中的较大值(其他基本类型方法相同)System.out.println(Math.max(123,121));//123System.out.println(Math.max(123.3,121.6));//123.3//public static double pow(double a, double b)	返回a的b次幂的值System.out.println(Math.pow(2,3));//8.0System.out.println(Math.pow(2.6,3.6));//31.182006138003036//public static double random()	返回double 类型的随机值范围[0.0,1.0]System.out.println(Math.random());//0.6261460302959388 随机数
}

2. System

        (1) System代表程序所在的系统,也是一个工具类

        (2) System类常见方法

方法说明
public static void exit(int status)终止当前运行的Java虚拟机--一般不会使用
public static long currentTimeMillis()返回当前系统时间的毫秒值(指的是从1970年1月1日 00:00:00到此刻的毫秒数) --1970年1月1日C语言的生日
public static void main(String[] args) {//System//public static void exit(int status)	终止当前运行的Java虚拟机//参数用作状态代码,按照惯例 非零状态代码表示异常终止  一般不会使用//System.exit(0);////public static long currentTimeMillis()	返回当前系统时间的毫秒值 一般用作计算程序运行时间//从1970-01-01 0:0:0开始 到此刻的毫秒值 1s = 1000毫秒Long time = System.currentTimeMillis();System.out.println(time);//1734449352827for (int i = 0; i < 1000000; i++) {System.out.println(i);}System.out.println("for循环共耗时:" + (System.currentTimeMillis() - time));
}

3. Runtime

        (1) Runtime代表程序所在的运行环境;是一个单例类

        (2) Runtime 常见方法

方法说明
public static Runtime getRuntime()返回与当前Java应用程序关联的运行时对象
public void exit(int status)终止当前运行的虚拟机;人为终止虚拟机,不要使用
public int availableProcessors()返回Java虚拟机可用的处理器数
public long totalMemory()返回Java虚拟机中的内存数量
public long freeMemory()返回Java虚拟机中的可用内存
public Process exec(String command) throws IOException启动某个程序,并返回代表该程序的对象
public static void main(String[] args) throws IOException, InterruptedException {//public static Runtime getRuntime()	返回与当前Java应用程序关联的运行时对象Runtime runtime = Runtime.getRuntime();//public void exit(int status)	终止当前运行的虚拟机//runtime.exit(0);//人为终止虚拟机 不要使用//public int availableProcessors()	返回Java虚拟机可用的处理器数System.out.println(runtime.availableProcessors());////public  long totalMemory()	返回Java虚拟机中的内存数量 返回的字节System.out.println(runtime.totalMemory() / 1024.0 / 1024.0 + "MB");//public long freeMemory()	返回Java虚拟机中的可用内存 返回的字节System.out.println(runtime.freeMemory() / 1024.0 / 1024.0 + "MB");//public Process exec(String command) throws IOException 参数为启动程序的路径	启动某个程序,并返回代表该程序的对象Process p =runtime.exec("E:\\QQ\\QQ.exe");Thread.sleep(5000);//等5000毫秒 = 5sp.destroy();//销毁/关闭启动某个程序
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com