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. 高效的CSS代码(2)

    ——阅读笔记,欢迎纠错^_^ 内容比较零散..... 1.让浮动元素的父容器根据元素的高度而自适应高度的方法: <div class="clearfix"><di ...

  2. 转:java.lang.OutOfMemoryError: Java heap space错误及处理办法(收集整理、转)

    以下是从网上找到的关于堆空间溢出的错误解决办法: Java.lang.OutOfMemoryError: Java heap space =============================== ...

  3. Python+selenium+eclipse+pydev自动化测试环境搭建

    一.        安装python 1.下载安装python 可访问python的官方网站:http://www.Python.prg找到下载页面下载需要的版本,可下载python2.x或者pyth ...

  4. SpringMvc开发步骤

    1.导入基本jar包 2.在Web.xml中配置DispatcherServlet <!-- 配置 DispatcherServlet --> <servlet> <se ...

  5. linux系统编程:自己动手写一个who命令

    who命令的作用用于显示当前有哪些用户登录到系统. 这个命令执行的原理是读取了系统上utmp文件中记录的所有登录信息,直接显示出来的 utmp文件在哪里呢? man who的时候,在手册下面有这么一段 ...

  6. 删除链表中间节点和a/b处的节点

    [题目]: 给定链表的头节点 head,实现删除链表的中间节点的函数. 例如: 步删除任何节点: 1->2,删除节点1: 1->2->3,删除节点2: 1->2->3-& ...

  7. Hadoop 2.6.0 完全分布式平台搭建

    一.准备软件环境: hadoop-2.6.0.tar.gz CentOS release 6.5 jdk-7u67-linux-x64.tar.gz 网络配置: master1            ...

  8. JSP动态产生的代码,点击显示确认操作,根据操作跳转并传值。

    假如有如下一段代码产生了多个选项我们改如何获得点击删除一项中的值? <%List<Theme> themelist=(List<Theme>)request.getAtt ...

  9. ssh框架实现员工部门增删改查源码

    http://pan.baidu.com/s/1qYLspDM 备注:IDE是eclipse,前端使用bootstrap,数据库是mysql

  10. 发布到ASP.NET CORE项目到 Windows server 2012

    原文: https://github.com/zeusro/MarkdownBlog/blob/master/2018/2018-01-17-01.md 发布到ASP.NET CORE项目到 Wind ...