Java Array

学习材料

https://joshhug.gitbooks.io/hug61b/content/chap2/chap24.html

Array Basic

Arrays are a special type of object that consists of a numbered sequence of memory boxes. This is unlike class instances, which have named memory boxes.

Declaration and instantiation

Example

  • int x; gives us a 32 bit memory box that stores ints.
  • Walrus w1; gives us a 64 bit memory box that stores Walrus references.
  • Walrus w2 = new Walrus(30, 5.6); gets us 3 total memory boxes. One 64 bit box that stores Walrus references, one 32 bit box that stores the int size of the Walrus, and a 64 bit box that stores the double tuskSize of the Walrus.

Array Creation

  • x = new int[3];
  • y = new int[]{1, 2, 3, 4, 5};
  • int[] z = {1, 2, 3, 4, 5};
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,419评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,797评论 0 23
  • 2018-04-30第十六篇原创文章 今天是四月份的最后一天,总觉得,我必须要留下点什么吧。 时间过得真快,如闪电...
    骨羽阅读 735评论 0 3
  • 昨天又忘了更新了今天早上起来才想起,不过还好有日更卡。今天星期一,晚上八点的时候有部门的入职感言,还没做好准备,...
    少的阅读 192评论 0 0