关于java中数组也是对象的强悍解释
来源:互联网 发布:薪酬数据分析方法统计 编辑:程序博客网 时间:2024/05/22 01:22
Object[] objs = new Object[3];
Object obj = objs;
objs = (Object[])obj;
Object obj = objs;
objs = (Object[])obj;
另外,下文对java中的数组的本质做了一些探讨:
http://dev.csdn.net/author/DeepNightTwo/afb7e220bdf5423ba656f84b6a183b44.html
另,
/*
* TestObjectArray.java, 2007-6-16 17:07:29.
*
* CopyRight (c) 2007-2007, yethyeth ,All rights reserved.
*
* This file is licenced under the Apache License.
*
*
* this file shows that object arrays is treated as objects.
*/
package cn.yethyeth.sample;
public class TestObjectArray {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Object[] objs = new Object[2];
objs[0] = new Integer(0);
objs[1] = new Integer(1);
Object obj = (Object)objs;
Object[] objs2 = (Object[])obj;
System.out.println(objs2[1]);
int[] is = new int[2];
is[0] = 0;
is[1] = 1;
Object obj1 = (Object)is;
System.out.println(obj1);
System.out.println(obj1.getClass() );
int[] iss = (int[])obj1;
System.out.println( iss[1]);
}
}
* TestObjectArray.java, 2007-6-16 17:07:29.
*
* CopyRight (c) 2007-2007, yethyeth ,All rights reserved.
*
* This file is licenced under the Apache License.
*
*
* this file shows that object arrays is treated as objects.
*/
package cn.yethyeth.sample;
public class TestObjectArray {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Object[] objs = new Object[2];
objs[0] = new Integer(0);
objs[1] = new Integer(1);
Object obj = (Object)objs;
Object[] objs2 = (Object[])obj;
System.out.println(objs2[1]);
int[] is = new int[2];
is[0] = 0;
is[1] = 1;
Object obj1 = (Object)is;
System.out.println(obj1);
System.out.println(obj1.getClass() );
int[] iss = (int[])obj1;
System.out.println( iss[1]);
}
}
结果:
1
[I@148cc8c
class [I
1
[I@148cc8c
class [I
1
- 关于java中数组也是对象的强悍解释
- 超强悍!面向对象概念深入浅出的图片解释
- 关于java的对象数组
- 关于java的对象数组
- java中对象句柄的解释
- 关于Java中类赋值的解释
- 关于java中main函数的解释
- java中关于方法的解释
- 如何查看类对象数组中类成员变量的全部值,类成员变量也是数组。
- 关于JAVA类对象数组的创建
- 关于面向对象的解释?
- Java学习笔记(一)——JAVA中关于对象数组的定义与使用
- 关于json数组拼接中对象的对象具体实现
- Java中对生成Class对象的解释
- Java中newString(abc)创建几个对象的解释
- java 中关于数组,对象,字符串分别占多少字节的问题
- Java中对象数组的使用
- Java中对象数组的详解
- Web Services 考试---搞笑版
- 掌握WEB控件的使用(二)
- VC学习摘要4
- C#连接两种数据库
- JS字符串 window.open() window.opener window.name window对象总结
- 关于java中数组也是对象的强悍解释
- 胡永凯的画
- 读取数据库
- 《越狱》中的项目管理之道
- 每日构筑,持续性构筑的重要性
- 能力拓展训练(WKB)感悟
- ASP.NET技术的学习顺序问题——看了以后也没什么,一部分借鉴吧!
- 大学要做的50件事
- 动态处理html表格