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

o2o平台搭建店铺seo是什么意思

o2o平台搭建,店铺seo是什么意思,泉州小程序开发科技公司,怎样优化网站appJava的API(1) 一、Math的API 是一个帮助我们进行数学计算的工具类私有化构造方法,所有的方法都是静态的(可以直接通过类名.调用) 平方根:Math.sqrt()立方根:Math.cbrt() 示例: p…

Java的API(1)

一、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}

数组拷贝的注意事项

  1. 如果数据源数组和目的地数组都是基本数据类型,那么两者的类型必须保持一致,否则会报错
  2. 在拷贝的时候需要考虑数组的长度,如果超出范围就会报错
  3. 如果数组源数组和目的地数组都是引用数据类型,那么子类类型可以赋值给父类类型(若要再次使用则需要强转)

示例

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/613775/

相关文章:

  • 腾龙时时彩做号网站整站优化关键词排名
  • 正规的网站制作与推广百度广告运营
  • 网站建设估价引擎搜索有哪些
  • 东莞网站建设选菲凡网络如何制作网站
  • 网站收录系统备案查询官网
  • 临朐县网站建设利用搜索引擎营销成功的案例
  • 利用网盘做视频网站镇江优化推广
  • 视频微网站开发哪个公司网站设计好
  • 品网站建设智能搜索引擎
  • 怎样在百度建网站seo建设者
  • 四海网络网站建设咨询什么叫做网络营销
  • 安徽建设网官方网站优化分析
  • 网站根目录文件名游戏推广员是做什么的
  • 个体工商户怎么做网站西安网站seo技术
  • 报名网站制作2345网址导航官网下载安装
  • 图书购物网站开发总结百度发广告需要多少钱
  • 做网站 业务流程图站长统计性宝app
  • 长沙做网站大概多少钱万网域名注册教程
  • 成都网站建设网站产品推广计划书怎么写
  • 深圳个人网站建设大连网络推广公司哪家好
  • 建设工程教育appseo技术培训中心
  • 家教中介怎么利用网站来做的免费广告推广
  • wordpress仿制建设seo是什么平台
  • 商城网站建设分为几块seo臻系统
  • 网络营销对于个人而言有什么作用seo文章
  • 做书籍封皮的网站今日中国新闻
  • 东莞建设网站电工培训技术学校
  • 深圳聘请做网站人员成都排名seo公司
  • 网站备案之后东莞网站关键词优化公司
  • 多种专业网站建设潍坊网站排名提升