Student类:
package com.itheima;
/*
* 自动生成构造方法:
* 代码区域右键 -- Source -- Generate Constructors from Superclass... 无参构造方法
* 代码区域右键 -- Source -- Generate Constructor using Fields... 带参构造方法
* 自动生成getXxx()/setXxx():
* 代码区域右键 -- Source -- Generate Getters and Setters...
*/
public class Student {
private String name;
private int age; public Student() { } public Student(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;
} }
Student的测试类:
package com.itheima;
/*
* 创建一个学生数组,存储三个学生对象并遍历
*
* 分析:
* A:定义学生类
* B:创建学生数组
* C:创建学生对象
* D:把学生对象作为元素赋值给学生数组
* E:遍历学生数组
*/
public class StudentDemo {
public static void main(String[] args) {
//创建学生数组
Student[] students = new Student[3]; //创建学生对象
Student s1 = new Student("曹操",40);
Student s2 = new Student("刘备",35);
Student s3 = new Student("孙权",30); //把学生对象作为元素赋值给学生数组
students[0] = s1;
students[1] = s2;
students[2] = s3; //遍历学生数组
for(int x=0; x<students.length; x++) {
Student s = students[x];
//System.out.println(s);
System.out.println(s.getName()+"---"+s.getAge());
}
}
}

对应的内存图:

Memory map of an object array的更多相关文章

  1. A memory map of an object

    Phone类 package com.itheima_02; /* * 手机类: * 成员变量:品牌,价格,颜色... * 成员方法:打电话,发短信... */ public class Phone ...

  2. map/set/object/array对比

    map () { //数据结构横向对比, 增,查,改,删 let map = new Map() let array = [] //增 map.set('t',1) array.push({t:1}) ...

  3. 再谈js对象数据结构底层实现原理-object array map set

    如果有java基础的同学,可以回顾下<再谈Java数据结构—分析底层实现与应用注意事项>:java把内存分两种:一种是栈内存,另一种是堆内存.基本类型(即int,short,long,by ...

  4. 五、jdk工具之jmap(java memory map)、 mat之四--结合mat对内存泄露的分析、jhat之二--结合jmap生成的dump结果在浏览器上展示

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

  5. ES6 Map vs ES5 Object

    ES6 Map vs ES5 Object Map vs Object https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc ...

  6. 笔记:Memory Notification: Library Cache Object loaded into SGA

    笔记:Memory Notification: Library Cache Object loaded into SGA在警告日志中发现一些这样的警告信息:Mon Nov 21 14:24:22 20 ...

  7. JS 深度拷贝 Object Array

    JS 深度拷贝 Object Array function cloneObj(o) { var isArray = o instanceof Array; var isObject = o insta ...

  8. 速战速决 (2) - PHP: 数据类型 bool, int, float, string, object, array

    [源码下载] 速战速决 (2) - PHP: 数据类型 bool, int, float, string, object, array 作者:webabcd 介绍速战速决 之 PHP 数据类型 boo ...

  9. jmap命令(Java Memory Map)(转)

    JDK内置工具使用 一.javah命令(C Header and Stub File Generator) 二.jps命令(Java Virtual Machine Process Status To ...

随机推荐

  1. 11、使用xamarin实现全屏播放rtmp之类的直播视频

    直播类的app大部分都是以rtmp hls播放为主.目前主流的app解决方案大部分是引入ijkplayer 这个是基于ffmpeg中的ffplayer实现的. 众所周知ffmpeg的解码能力是一流的. ...

  2. django第三课 模版

    第一步 创建项目文件: django-admin.py startproject *** 第二步 进入该文件下创建文件夹templates,在该文件夹下创建thanks.html <!DOCTY ...

  3. python 把一文件包含中文的字符写到另外文件乱码 UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position

    报错的代码是: file2 = open('target.txt','w')for line in open('test.txt'): file2.write(line)原因:文件编码不一致导致解决方 ...

  4. 2013-12-LINUX 常用命令

    查看iptables状态: service iptables status 查询LINUX开机时间多久 1. cat /proc/uptime输出: 105040.44 105024.75 秒 2. ...

  5. 【数组】Product of Array Except Self

    题目: iven an array of n integers where n > 1, nums, return an array output such that output[i] is ...

  6. linux内核移植过程问题总结

    移植内核:2.6.30.4内核根目录下的.config为当前配置内核的且已经配置好的内核配置.make zImage以此为依据配置内核的过程:cd linux-2.6.30.4(进入Linux根目录) ...

  7. mysql数据库修改字符编码问题

    遇到这种情况,现有项目的数据库已经建好,数据表也已经创建完成. 问题来的,数据库不能插入中文,调试时候发现中文数据从发送请求到最后请求处理完成这些步骤,中文还没有发生乱码. 只有在存储到数据库后查询数 ...

  8. android学习-异步消息处理机制

    消息处理机制主要对象:Looper,Handler,Message(还有MessageQueue和Runnable) Looper不断从MessageQueue消息队列中取出一个Message,然后传 ...

  9. Impala 使用的端口

    下表中列出了 Impala 是用的 TCP 端口.在部署 Impala 之前,请确保每个系统上这些端口都是打开的. 组件 服务 端口 访问需求 备注 Impala Daemon Impala 守护进程 ...

  10. Java中的四种引用

    引用定义 实际上,Java中存在四种引用,它们由强到弱依次是:强引用.软引用.弱引用.虚引用.下面我们简单介绍下这四种引用: 强引用(Strong Reference):通常我们通过new来创建一个新 ...