首页 > 其他分享 >API

API

时间:2023-01-19 15:45:07浏览次数:45  
标签:getRuntime System API println Runtime Math out

  1. Math:
    //abs表示返回绝对值
    /*System.out.println(Math.abs(-88));
    //ceil表示向上取整,向正无穷方向获取最近的整数
    System.out.println(Math.ceil(11.1));
    //floor表示向下取整,相当于去尾,向负无穷方向获取最近的整数
    System.out.println(Math.floor(2.2));

    //round表示四舍五入
    System.out.println(Math.round(-12.54));//13
    //Max表示获取两个数之间的最大值
    System.out.println(Math.max(3, 5));
    //Min表示获取两个数之间的最小值
    System.out.println(Math.min(3, 5));
    //pow获取a的b次幂
    System.out.println(Math.pow(2, 3));
    //sqrt表示开平方根
    System.out.println(Math.sqrt(4));
    //cbrt表示开立方根
    System.out.println(Math.cbrt(8));
    //random()获取一个double类型的随机数,范围是[0.0,1)
    System.out.println(Math.round(2));
    */
  2. System:
     //方法形参是一个状态码
    //0表示正常停止,非0表示异常停止
    // java.lang.System.exit(0);
    //System.currentTimeMillis();表示返回系统的时间毫秒值形式
    //long l = java.lang.System.currentTimeMillis();
    //System.out.println(l);

    /*System.arraycopy拷贝数组
    参数一;数据源,表示要拷贝的数组来自哪里
    参数二:从数据源数组中的第几个索引开始拷贝
    参数三;目的地数组,我要把数据拷贝到哪个数组中
    参数四:目的地数组的索引
    参数5:拷贝的个数*/
    int[] array1= {1,2,3,4,56,7,8,9,10};
    int[] array2 =new int[10];
    java.lang.System.arraycopy(array1,0,array2,0,array1.length);
  3. Runtime:
     //1:获取Runtime对象
    //Runtime runtime = Runtime.getRuntime();
    //2:exit关闭虚拟机
    //Runtime.getRuntime().exit(0);
    //3:获取CPU线程数
    /* System.out.println(Runtime.getRuntime().availableProcessors());
    //总内存大小,单位是byte
    System.out.println(Runtime.getRuntime().maxMemory());
    //已经获取的总内存大小,单位是byte
    System.out.println(Runtime.getRuntime().totalMemory());
    //剩余内存的大小
    System.out.println(Runtime.getRuntime().freeMemory());
    //运行cmd命令
    //shutdown关机,需要加上参数
    //-s默认在一分钟后关机
    //-s -t 加时间:指定关机时间
    //-a取消关机操作
    //-r关机并重启
    Runtime.getRuntime().exec("notepad");
    // Runtime.getRuntime().exec("shutdown -s -t 1200")*/

标签:getRuntime,System,API,println,Runtime,Math,out
From: https://www.cnblogs.com/lyjzht/p/17061633.html

相关文章

  • kettle 创建资源库 Java api DatabaseRepository
    创建资源库前置mysql数据库test核心代码KettleEnvironment.init();DatabaseMetadatabaseMeta=newDatabaseMeta("test-db","MYSQL","Native",......
  • HBase API
    1环境准备新建项目后在pom.xml中添加依赖:注意:会报错javax.el包不存在,是一个测试用的依赖,不影响使用<dependencies><dependency><groupId>org.apache.hbase......
  • Strapi & headless CMS All In One
    Strapi&headlessCMSAllInOneStrapi-OpensourceNode.jsHeadlessCMS......
  • drf快速使用 CBV源码分析 drf之APIView分析 drf之Request对象分析
     目录序列化和反序列化drf介绍和安装使用原生django写接口djangoDRF安装drf快速使用模型序列化类视图路由datagrip使用postman测试接口CBV源码分......
  • 学习笔记——定义切面优先级 ;Spring中的JdbcTemplate;JdbcTemplate的常用API
    2023-01-18一、定义切面优先级  1、语法:@Order(value=index)①index是int类型,默认值是int可存储的最大值②数值越小,优先级越高二、Spring中的JdbcTemplate1、JdbcT......
  • Centos7 部署NetCore6.0 Web Api
    一、安装dotnet环境第一步sudorpm-Uvhhttps://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm第二步sudoyuminstalldotnet-sdk-6.0......
  • Python使用pyppeteer搭建网页截图api
    因为跨语言需要,打算把pyppeteer、图片压缩、awsS3封装成一个api来调用。首先自然是要安装依赖pip3installpillowboto3pyppeteer运行一次脚本,pyppeteer会自动下载最......
  • day14-常用API
    1.API1.1API概述【理解】什么是API​ API(ApplicationProgrammingInterface):应用程序编程接口java中的API​ 指的就是JDK中提供的各种功能的Java类,这些类......
  • day15-常用API
    1.时间日期类1.1Date类(应用)计算机中时间原点1970年1月1日00:00:00时间换算单位1秒=1000毫秒Date类概述Date代表了一个特定的时间,精确到毫秒Date类构......
  • xlwings rest api
    https://pbihub.cn/blog/964/created_athttps://docs.xlwings.org/zh_CN/latest/rest_api.htmlxlwings>=0.13.0flask>=1.01.运行CMD xlwingsrestapirun-host0.......