java.lang.Reflect.Array类提供了动态创建和访问数组元素的各种静态方法。

package com.sunchao.reflection;

import java.lang.reflect.Array;

/**
* The array reflection.
* @author Administrator
*
*/
public class ArrayReflection { public static void main(String args[]) throws Exception {
Class<?> clazz = Class.forName("java.lang.String");
String[] array = (String[]) Array.newInstance(clazz, 10);
Array.set(array, 5, "hello world");
String index5= (String) Array.get(array, 5);
System.out.println(index5);
System.out.println(array[5]);
System.out.println(int.class);
System.out.println(Integer.class);
System.out.println(Integer.TYPE);
}
}

Integer.TYPE 是int的class类型封装 == int.class

hello world
hello world
int
class java.lang.Integer
int

Reflection and array的更多相关文章

  1. Java和C#基本类库的区别

    java.lang java .net Boolean System.Boolean Byte System. Byte Character System.Char Class System.Type ...

  2. Java反射机制(Reflection)

    Java反射机制(Reflection) 一.反射机制是什么 Java反射机制是程序在运行过程中,对于任意一个类都能够知道这个类的所有属性和方法;对于任意一个对象都能够调用它的任意一个方法和属性,这种 ...

  3. PHP : Reflection API

    PHP Reflection API是PHP5才有的新功能,它是用来导出或提取出关于类.方法.属性.参数等的详细信息,包括注释. PHP Reflection API有: class Reflecti ...

  4. [Java Basics2] Iterable, Socket, Reflection, Proxy, Factory DP

    Parent interface of Collection: Iterable Interface A class that implements the Iterable can be used ...

  5. PHP 反射机制Reflection

    简介 PHP Reflection API是PHP5才有的新功能,它是用来导出或提取出关于类.方法.属性.参数等的详细信息,包括注释. class Reflection { } interface R ...

  6. angular2 学习笔记 (Typescript - Attribute & reflection)

    refer : https://www.npmjs.com/package/reflect-metadata refer : https://www.typescriptlang.org/docs/h ...

  7. Java反射(Reflection)

    基本概念 在Java运行时环境中,对于任意一个类,能否知道这个类有哪些属性和方法?对于任意一个对象,能否调用它的任意一个方法? 答案是肯定的. 这种动态获取类的信息以及动态调用对象的方法的功能来自于J ...

  8. TypeScript: Week Reflection

    TypeScript: Week Reflection Introduction Type Script already provide decorators to help developers i ...

  9. csharp: Setting the value of properties reflection

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

随机推荐

  1. Python的伪私有属性

    什么是伪私有属性? 在Python中,没有类似 private 之类的关键字来声明私有方法或属性. Python中要声明私有属性,需要在属性前加上双下划线(但是结尾处不能有双下划线),如:self._ ...

  2. MicroPython支持的开发板:高性能、低成本创客首选

    Python的开放.简洁.黏合正符合了现发展阶段对大数据分析.可视化.各种平台程序协作产生了快速的促进作用.自Python3的发布到现在已有五六年的时间,从刚发布的反对声音到慢慢被接受与喜欢经过了太漫 ...

  3. Mac安装Homebrew

    Homebrew的安装,打开终端复制.粘贴以下命令,回车 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/i ...

  4. Unity3d 动态加载场景物件与缓存池的使用

    聊聊Unity3d动态加载场景物件那些事儿. 众所周知,在策划或美术设计完游戏场景地图后,一个场景中可能会存在成千上万个小的物件,比如石头,木箱子,油桶,栅栏等等等等,这些物件并不是游戏中的道具,仅仅 ...

  5. web服务器,应用程序服务器,http服务器的区别

    WEB服务器.应用程序服务器.HTTP服务器有何区别?IIS.Apache.Tomcat.Weblogic.WebSphere都各属于哪种服务器? 这个概念很重要. Web服务器的基本功能就是提供We ...

  6. visualSVN 版本控制

    用SmartSVN提交代码的时候提示:svn: File has inconsistent newlines 这是由于要提交的文件编码时混合了windows和unix符号导致的. 解决方法: Proj ...

  7. C/C++知识点清单02-上

    第二章 预处理.const.static与sizeof (上) 在这章编写时,发现了一个不错的帖子.其中对程序预处理语句的基本概念写得还是十分清晰的. (http://www.runoob.com/c ...

  8. https 与 http

    HTTPS,HTTP over SSL,SSL是解决传输层安全问题的网络协议,其核心是基于公钥密码学理论实现了对服务器身份认证,数据的私密性保护以及对数据完整性的校验等功能. SSL协议在HTTP请求 ...

  9. Babel 转码器 § es6转换es5

    Babel 转码器 § es6转换es5 实时转码 /  Repl  -babel-node / babel-register(自动转码引入babel-register模块) 配置文件.babelrc ...

  10. 牛客网linux试题-错误整理-20170914

    Linux操作系统包括三种不同类型的进程,每种进程都有自己的特点和属性. 1.交互进程--由一个shell启动的进程.交互进程既可以在前台运行,也可以在后台运行. 2.批处理进程--这种进程和终端没有 ...