day09

作者: zhuofai | 来源:发表于2018-08-23 19:46 被阅读0次

数组

  1. 数组硕果仅存的优点就是效率.
  2. 新生成一个数组对象时,其中所有的引用被自动初始化为null,所以检查其中的引用是否为null,即可知道数组的某个位置是否存有对象.同样基本类型的数组如果是数值型的,就被自动初始化为0,如果时字符型(char)的,就被自动初始化为(char)0;如果是布尔值(boolean),就被自动初始化为false.
  3. Arrays.deepToString()方法,它可以将多维素组转换为多个String.它对基本类型数组和对象数组都起作用.
  4. System.arraycopy()
  • public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)

Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array. A subsequence of array components are copied from the source array referenced by src to the destination array referenced by dest. The number of components copied is equal to the length argument. The components at positions srcPos through srcPos+length-1 in the source array are copied into positions destPos through destPos+length-1, respectively, of the destination array.
Parameters:
src - the source array.
srcPos - starting position in the source array.
dest - the destination array.
destPos - starting position in the destination data.
length - the number of array elements to be copied.

动态初始化:

  • 数据类型[] 数组名 = new 数据类型[长度];
  • 数据类型:--->决定了数组能够存放什么样的数据
  • [] :---->代表是一个数组
  • 数组名 :--->为数组起的名字,为了找到数组
  • new:---> 向堆内存申请空间的关键字
  • 长度: --->数组中能够存放多少个数据
  • 特点: 我们程序员给定长度,由系统给定默认值!!!

静态初始化:

完整的格式: 数据类型[] 数组名 = new 数据类型[不能写长度!!!!]{元素1,元素2...};
省略的格式:
数据类型[] 数组名 = {元素1,元素2...};
内存划分
*栈
1. 存放局部变量 ----> 定义在方法里面,或者方法声明上(参数列表)的变量都是局部变量
2. 所有的方法都在栈里面运行
3. 堆:
4. 作用:存放new出来的东西
5. 特点:1.都有地址值2.都有默认值整数: 0 小数:0.0 字符:'\u0000 布尔:false 引用数据类型:null

方法区

  • 存放字节码对象.class相关的信息
  • 存放静态相关的东西static
  • 本地方法栈 ---->系统相同
  • 寄存器 --->cpu

获取数组的长度
格式:数组名.length

相关文章

  • 自律给我自由—Day009

    【叶子姑娘的自律100天挑战 Day09】 2019.01.23 Day09/100 【早起】第十二天早起。 【阅...

  • 三阶段day09-前后分离、ajax

    day09: 前后分离,ajax 前后分离 ajax

  • 四、canvas

    阻止IE6下的默认行为:image.png day09

  • 2018-12-16

    Day09 Object、日期与时间、System、StringBuilder、包装类 1.Object类 1.1...

  • 五、canvas(使用图片&设置背景)

    在canvas中插入图片(需要image对象) 在canvas中设置背景(需要image对象) 渐变 day09

  • Day09

    学习了,abstract. final. 内部类,包,继承,接口,interface 和implements 抽象...

  • day09

    数组 数组硕果仅存的优点就是效率. 新生成一个数组对象时,其中所有的引用被自动初始化为null,所以检查其中的引用...

  • Day09

    变量作用域 字符串 基本概念 字符串内存分析 字符串输出和输入字符串输出: puts(str); 字符串输入: g...

  • day09

    今天学了什么 1.字符串常用的方法 1.1 length 获取字符串的长度 1.2增加 concat() 方法用...

  • day09

    A今天学了什么 1.animation 动画 B今天学会了什么 1.animation 动画 C今天没掌握什么

网友评论

      本文标题:day09

      本文链接:https://www.haomeiwen.com/subject/kynmiftx.html