Reflection and array
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的更多相关文章
- Java和C#基本类库的区别
java.lang java .net Boolean System.Boolean Byte System. Byte Character System.Char Class System.Type ...
- Java反射机制(Reflection)
Java反射机制(Reflection) 一.反射机制是什么 Java反射机制是程序在运行过程中,对于任意一个类都能够知道这个类的所有属性和方法;对于任意一个对象都能够调用它的任意一个方法和属性,这种 ...
- PHP : Reflection API
PHP Reflection API是PHP5才有的新功能,它是用来导出或提取出关于类.方法.属性.参数等的详细信息,包括注释. PHP Reflection API有: class Reflecti ...
- [Java Basics2] Iterable, Socket, Reflection, Proxy, Factory DP
Parent interface of Collection: Iterable Interface A class that implements the Iterable can be used ...
- PHP 反射机制Reflection
简介 PHP Reflection API是PHP5才有的新功能,它是用来导出或提取出关于类.方法.属性.参数等的详细信息,包括注释. class Reflection { } interface R ...
- angular2 学习笔记 (Typescript - Attribute & reflection)
refer : https://www.npmjs.com/package/reflect-metadata refer : https://www.typescriptlang.org/docs/h ...
- Java反射(Reflection)
基本概念 在Java运行时环境中,对于任意一个类,能否知道这个类有哪些属性和方法?对于任意一个对象,能否调用它的任意一个方法? 答案是肯定的. 这种动态获取类的信息以及动态调用对象的方法的功能来自于J ...
- TypeScript: Week Reflection
TypeScript: Week Reflection Introduction Type Script already provide decorators to help developers i ...
- csharp: Setting the value of properties reflection
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
随机推荐
- JavaScript 内存相关知识
一.内存基本概念 1.1.生命周期 不管什么程序语言,内存生命周期基本是一致的: 分配你所需要的内存 var n = 123; // 给数值变量分配内存 var s = "azerty&qu ...
- Kotlin——最详细的操作符与操作符重载详解(上)
本篇文章为大家详细的介绍Koltin特有的操作符重载.或许对于有编程经验的朋友来说,操作符这个词绝对不陌生,就算没有任何编辑基础的朋友,数学中的算数运算符也绝不陌生.例如(+.-.*./.>.& ...
- Web App、Hybrid App与Native App
在这个App的时代,转战了前端,一直接触的都是pc, 离out不远了. 那么接下来,app是我接下来半年的重点,为什么是半年,因为时间不多了. 因为是前端,那么我的重心肯定是 Web App, Hyb ...
- webapi框架搭建-依赖注入之autofac
前言 c#的依赖注入框架有unity.autofac,两个博主都用过,感觉unity比较简单而autofac的功能相对更丰富(自然也更复杂一点),本篇将基于前几篇已经创建好的webapi项目,引入au ...
- mongodb 创建用户
1.创建管理员 2.授权认证 3.给使用的数据库添加用户 普通连接(非授权连接)数据库 mongod -f /usr/local/etc/mongod.conf 授权连接数据库 mongod -f / ...
- 移动端吸顶(iOS与安卓)
有的时候经常会遇到移动端吸顶效果,开始我也只是上网查了一下,分别有iOS和android两种样式,如下: /*!*Android*!*/ .head { position: fixed; top: 0 ...
- [].slice.call(arguments,1)
[转] 前言 今天偶然翻资料看到一个叫做软绑定的函数,用来确定this的; 原代码 if(!Function.prototype.softBind){ Function.prototype.softB ...
- 格式化 输出 while ,else ASCII码 ,字节转换 ,逻辑运算
python (占位符) % (求余数) 示例 name = input("请输入你的名字") age =int(input("请输入你的年龄")) hei ...
- 利用python写一个简单的小爬虫 爬虫日记(1)(好好学习)
打开py的IDLE >>>import urllib.request >>>a=urllib.request.urlopen("http://www.ba ...
- bzoj:3398 [Usaco2009 Feb]Bullcow 牡牛和牝牛
Description 约翰要带N(1≤N≤100000)只牛去参加集会里的展示活动,这些牛可以是牡牛,也可以是牝牛.牛们要站成一排.但是牡牛是好斗的,为了避免牡牛闹出乱子,约翰决定任意两只牡 ...