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

Java基础——常用API2

一、System

1.1 计算机中的时间原点

它表示最初的开始时间,是1970年1月1日00.00。

在我们国家,因为时差的原因实际上是:

那么这句话的意思就是,从时间原点开始到现在你执行这个代码一共过了多少毫秒。

package com.lkbhua.MyApi.System;public class demo2 {public static void main(String[] args){// -------------------------------数据源数组------起始索引-----目的地数组------起始索引-------拷贝个数// 3、public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length): 数组拷贝// 细节:// 1、如果数组源和目的数组都是基本数据类型,那么两者的类型一定要保持一致,否则会报错int []arr = {1,2,3,4,5,6,7,8,9,10};double []arr1 = new int[10];System.arraycopy(arr, 0, arr1, 0, arr.length);for (int i = 0; i < arr1.length; i++) {System.out.print(arr1[i] + " ");}// 2、在拷贝的时候需要考虑数组的长度,如果超过范围也会报错int []arr2 = {1,2,3,4,5,6,7,8,9,10};int []arr3 = new int[5];System.arraycopy(arr2, 0, arr3, 0, arr2.length);for (int i = 0; i < arr3.length; i++) {System.out.print(arr3[i] + " ");}// 3、如果数组源和目的数组都是引用数据类型,那么子类类型可以赋值给父类类型Student s1 = new Student("张三", 18);Student s2 = new Student("李四", 19);Student s3 = new Student("王五", 20);Student []students = {s1,s2,s3};Person []students1 = new Student[3];// 4、数组拷贝System.arraycopy(students, 0, students1, 0, students.length);// 只不过遍历的时候需要强转for (int i = 0; i<arr2.length;i++){Student stu = (Student)students1[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);}
}

声明:

以上均来源于B站@ITheima的教学内容!!!

本人跟着视频内容学习,整理知识引用

http://www.dtcms.com/a/549928.html

相关文章:

  • 自己做的网站能上传到凡科吗网站站点多少钱
  • 手机如何网站成都哪里好玩
  • huggingface下载相关
  • rollup == JavaScript 打包器
  • ROS2 Windows安装
  • 四川省建设厅招标网站网站与网页 主页的概念及它们的区别
  • Unity编辑器扩展入门篇 - Unity Inspector自定义脚本菜单
  • Redis(一)——数据类型一
  • 专业网站建设分为8步代注册公司要多少钱
  • 网站建设 网页设计 网站制作南宁哪个网络公司建网站好
  • Xilinx官网评估板链接
  • 【参赛心得】我的 HarmonyOS 开发入门与参赛之路
  • 答题PK小程序:在竞技与学习的夹缝中狂奔
  • 网站书店建设背景wordpress主页删除
  • 非蛋白氨基酸
  • Rust 移动语义(Move Semantics):内存安全的隐形守护者
  • 怎么用flash做网站app 网站 同时做
  • 摄影网站规划设计书建设官网电话号码
  • 性价比高的电磁阀生产厂家
  • WPF编译出现包问题
  • CZ个人持仓不足1%社区BNB做多情绪高涨,平台XBIT展现去中心化理念
  • 查网站的关键词排名吗重庆铜梁网站建设报价
  • STM32中 ESP8266 MQTT ModBus RS482 介绍
  • 代理分佣后台网站开发品牌网站建设制作
  • 网站建设 汇卓湖南做网站 磐石网络引领
  • 网络营销工程师有用吗优化设计七年级上册数学答案
  • 一文读懂计算机网络参考模型(二)
  • ALIGN 和 ROUND_UP 宏的原理与区别详解
  • 河南智慧团建官网企业网站建设优化
  • vue3 以el-icon方式使用iconfont上的图标