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 ...
随机推荐
- ASP.NET MVC框架开发系列教程
本系列教程是自己在工作中使用到而记录的,如有错误之处,请给与指正 文章目录 MVC4 开篇 第一章 初识MVC4 第二章 下山遇虎(@helper) 第三章 Models模块属性详解 第四章 在MVC ...
- table-cell实现未知宽高图片,文本水平垂直居中在div
<BODY> <h1>未知宽高的图片水平垂直居中在div</h1> <!--box-outer--> <div class="box-o ...
- Java学习笔记27(集合框架一:ArrayList回顾、Collection接口方法)
集合:集合是java中提供的一种容器,可以用来存储多个数据 集合和数组的区别: 1.数组的长度是固定的,集合的长度是可变的 2.集合中存储的元素必须是引用类型数据 对ArrayList集合的回顾 示例 ...
- 【STL深入理解】vector
这篇文章不打算讲述vector的基本用法,而是总结一下近期我大量阅读C++经典书籍时遇到的一些关于vector的容易忽略的知识点,特意将它们记录下来,以便以后查阅. 1.v[0]和v.at(0)的区别 ...
- 【括号问题】$("li:lt(" + (idx + 1) + ")") 手风琴效果注意事项
$("li:lt(" + (idx + 1) + ")").each(function(i){ 注意,这里必须要加括号,是因为如果不加,idx与前面 &quo ...
- 【Core2.0帮助类】
缓存帮助类(CacheHelper) /// <summary> /// 缓存帮助类 /// </summary> public class CacheHelper {//下载 ...
- weui 中的tabbar导航
最近做微信的服务号项目,用的weui作为主要的ui,但是对于用惯了ele ui的开发者来说,文档貌似有点不友好.真是很让人头疼! 所以结合着自己做的项目,随便写一点东西. 比如说,tabbar导航的切 ...
- 【三十三】thinkphp之SQL查询语句(全)
一:字符串条件查询 //直接实例化Model $user=M('user1'); var_dump($user->where ('id=1 OR age=55')->select()); ...
- [hdu3943]K-th Nya Number
挺正常的一道模板题. f[i][j][k]表示i位的数,有j个4,k个7的方案数. 具体实现的话...我写了发二分答案..需要注意的是二分时应该是mid=L+(R-L)/2..不然分分钟爆longlo ...
- BZOJ3916: [Baltic2014]friends
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=3916 复习一下hash(然后被傻叉错误卡了半天TAT... 取出一个字串:h[r]-h[l-1 ...