当前位置: 首页 > news >正文

网页网站公司如何做备份广西最优秀的品牌网站建设公司

网页网站公司如何做备份,广西最优秀的品牌网站建设公司,百度南京代理商,线上平面设计培训Java的API#xff08;1#xff09; 一、Math的API 是一个帮助我们进行数学计算的工具类私有化构造方法#xff0c;所有的方法都是静态的#xff08;可以直接通过类名.调用#xff09; 平方根#xff1a;Math.sqrt()立方根#xff1a;Math.cbrt() 示例#xff1a; p…Java的API1 一、Math的API 是一个帮助我们进行数学计算的工具类私有化构造方法所有的方法都是静态的可以直接通过类名.调用 平方根Math.sqrt()立方根Math.cbrt() 示例 public class MathDemo1 {public static void main(String[] args) {// Math类在Java的lang包中所以不需要引入// 且都是静态方法可以直接通过类名.直接调用// 绝对值System.out.println(Math.abs(-123.456)); // 123.456System.out.println(Math.abs(-156)); // 156// 向上取整(只要小数有值就会向整数上进)(往数轴的正方向进一)System.out.println(Math.ceil(123.3)); // 124.0System.out.println(Math.ceil(123.9)); // 124.0System.out.println(Math.ceil(-12.34)); // -12.0// 向下取整(小数的值直接舍弃)(往数轴的负方向减一)System.out.println(Math.floor(0.3)); // 0.0System.out.println(Math.floor(0.9)); // 0.0System.out.println(Math.floor(5.999999)); // 5.0System.out.println(Math.floor(-12.34)); // -13.0// 四舍五入满五向整数位进一(向数轴的两端进一)System.out.println(Math.round(5.363)); // 5System.out.println(Math.round(5.5)); // 6System.out.println(Math.round(5.6666)); // 6System.out.println(Math.round(-12.33)); // -12System.out.println(Math.round(-12.56)); // -13// 获取两个int值中的较大值(当两个不同数据类型的变量进行比较时会转化成精确度大的一方再进行比较)System.out.println(Math.max(3, 100000)); // 100000System.out.println(Math.max(2, 3.0)); // 3.0System.out.println(Math.max(3.14, 9)); // 9.0// 次幂(a的b次幂),返回值和参数值都是double类型System.out.println(Math.pow(3, 2)); // 9.0System.out.println((int)Math.pow(2, 4)); // 16// 返回double类型的随机数范围是 [0.0, 1.0)System.out.println(Math.random()); // 0.123456 (示例输出实际输出会随机)// 开平方根System.out.println(Math.sqrt(4)); // 2.0// 开立方根System.out.println(Math.cbrt(8)); // 2.0} }二、System的API System也是一个工具类提供一些与系统相关的方法 1、exit终止虚拟机 public static void exit(int status)——终止当前运行的JAVA虚拟机 // 终止当前的虚拟机// 方法形参的状态码// 0——表示当前虚拟机是正常停止// 非0——表示当前虚拟机是异常停止System.exit(0);System.out.println(看看我执行了吗); // 程序已经结束不会再执行2、currentTimeMillis()和nanoTime()返回当前系统时间 public static long currentTimeMillis()——返回当前系统的时间毫秒和纳秒值 // 返回当前系统的时间毫秒值形式(表示从计算机的时间原点C语言的生日1970.1.1.08:00:00(国内),当程序运行的时间)long l System.currentTimeMillis();System.out.println(l);该方法可以用来获取程序运行的总时间分析对比时间复杂度 示例对比两种方法判断质数的时间 int o 9489997;// 示例判断质数的两种时间复杂度 // long c System.currentTimeMillis();long c System.nanoTime();for (int i 2; i o; i) {if(o % i 0) {System.out.println(该数不是质数);break;}} // long a System.currentTimeMillis();long a System.nanoTime();// 一个非质数会在该数的平方根前面会出现可以被整除的数以此可以来提高效率for (int i 2; i Math.sqrt(o); i) {if(o % i 0) {System.out.println(该数不是质数);break;}} // long b System.currentTimeMillis();long b System.nanoTime();System.out.println(第一种方法时间为 (a - c) 纳秒); // 输出 第一种方法时间为23300纳秒System.out.println(第二种方法时间为 (b - a) 纳秒); // 输出 第二种方法时间为19900纳秒3、arraycopy()进行数组的拷贝 public static void arraycopy(数据源数组起始索引目的地数组起始索引拷贝个数)——数组拷贝 // 拷贝数组int[] arr1 {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};int[] arr2 new int[10];// 把arr1数组中的数据拷贝到arr2数组中// 参数一 数据源要拷贝的数据从哪个数组而来// 参数二 从数据源数组中的第几个索引开始拷贝// 参数三 拷贝的目的地要拷贝到哪个数组// 参数四 目的地数组的起始索引// 参数五 拷贝的个数 // System.arraycopy(arr1, 0, arr2, 0, 10);System.arraycopy(arr1, 0, arr2, 4, 3);for (int i 0; i arr2.length; i) {System.out.print(arr2[i] ); // 输出 0 0 0 0 1 2 3 0 0 0}数组拷贝的注意事项 如果数据源数组和目的地数组都是基本数据类型那么两者的类型必须保持一致否则会报错在拷贝的时候需要考虑数组的长度如果超出范围就会报错如果数组源数组和目的地数组都是引用数据类型那么子类类型可以赋值给父类类型若要再次使用则需要强转 示例 public class SystemDemo2 {public static void main(String[] args) {Student s1 new Student(小明, 20);Student s2 new Student(小资, 21);Student s3 new Student(小兰, 22);Student[] arr1 {s1, s2, s3};Person[] arr2 new Person[3];// 把arr1中的对象的地址赋值给arr2中System.arraycopy(arr1, 0, arr2, 0, 3);// 遍历数组arr2for (int i 0; i arr2.length; i) {Student stu (Student)arr2[i];System.out.println(stu.getName() stu.getAge());}} }class Person {private String name;private int age;public Person() {}public Person(String name, int age) {this.name name;this.age age;}public String getName() {return name;}public void setName(String name) {this.name name;}public int getAge() {return age;}public void setAge(int age) {this.age age;} }class Student extends Person {public Student() {}public Student(String name, int age) {super(name, age);} }三、Runtime的API Runtime表示当前虚拟机的运行环境 示例 public class RuntimeDemo1 {public static void main(String[] args) throws IOException {// 1、获取Runtime的对象Runtime r1 Runtime.getRuntime();// 2、虚拟机的终止// 0————正常终止虚拟机// 非0值————异常终止虚拟机 // Runtime.getRuntime().exit(0); // System.out.println(看看我执行了吗); // 不会执行// 3、获取CPU的线程数System.out.println(Runtime.getRuntime().availableProcessors()); // 4、获取总内存的大小单位byte字节System.out.println(Runtime.getRuntime().maxMemory() / 1024 / 1024); // 5、已经占用的内存的大小单位byte字节System.out.println(Runtime.getRuntime().totalMemory() / 1024 / 1024);// 6、剩余的内存的大小单位byte字节System.out.println(Runtime.getRuntime().freeMemory() / 1024 / 1024);// 7、运行cmd命令// 打开记事本Runtime.getRuntime().exec(notepad);// shutdown:关机// 加上参数才能执行// -s : 默认在1分钟之后关机// -s -t 指定时间 指定关机时间// -a : 取消关系操作// -r 关闭并重启 // Runtime.getRuntime().exec(shutdown -s -t 36000);Runtime.getRuntime().exec(shutdown -a);} }
http://www.hkea.cn/news/14336088/

相关文章:

  • 网站的收费标准怎么创建网页
  • 衡水做网站推广找谁专门做护肤品的网站是
  • 石家庄建设公司网站个人做网站有什么用
  • 除了亚马逊还有啥网站做海淘农业银行官网
  • 重庆开县网站建设公司网站制作网络推广方案
  • 企业网站建设公司选择分析pc端网游排行榜前十名
  • 淘宝网站页面设计it培训机构课程
  • 手机号注册网站做网站的公司都很小吗
  • 泰来县城乡建设局网站如东网站开发
  • 印刷东莞网站建设技术支持asp网站 打开
  • 网站建设佛山拓客科技仿阿里百秀网站模板
  • 咨询服务公司网站建设怎么提高网站权重
  • 网站ip做网站一个页面的html5网站模板 psd
  • 卖渔具的亲戚做网站百度网站的安全建设方案
  • 一家专业做家谱的网站摄影网站建设
  • 网站建设丶金手指C排名15怎么自己做网站qq
  • 自己的服务器 做网站8小8x在线免费观看2021
  • h5页面制作网站免费深圳网站建设 制作元
  • 潍坊快速网站排名彩页设计素材
  • 网站聊天怎么做免费个人网站服务器 html
  • linux系统网站建设网站推广的方案设计怎么写
  • 外围网站做代理成都建设网站费用
  • 上海专业高端网站建设网站弄好了怎么推广
  • 外国人学做中国菜 网站沈阳市住房和城乡建设部网站
  • 甘肃省城乡与住房建设厅网站首页有wordpress模板安装教程视频教程
  • 做钢材的都用什么网站免费的网站管理系统
  • 做游戏网站的目地做网站需要自备服务器吗
  • 如何做好网站内容wordpress媒体库图片不显示
  • app软件开发平台有哪些googleseo優化
  • 国内网站建设阿里云潍坊网站建设推广公司