?? yeekuarray.java
字號:
import java.lang.reflect.*;
/**
* Description:
* <br/>Copyright (C), 2008-2010, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class YeekuArray
{
//對Array的newInstance方法進行包裝
public static <T> T[] newInstance(Class<T> componentType, int length)
{
return (T[])Array.newInstance(componentType , length);
}
public static void main(String[] args)
{
//使用YeekuArray的newInstance()創建一維數組
String[] arr = YeekuArray.newInstance(String.class , 10);
//使用YeekuArray的newInstance()創建二維數組
//在這種情況下,只要設置數組元素的類型是int[]即可。
int[][] intArr = YeekuArray.newInstance(int[].class , 5);
arr[5] = "ROR敏捷開發最佳實踐";
//intArr是二維數組,初始化該數組的第二個數組元素——數組元素必須是一維數組
intArr[1] = new int[]{ 23, 12};
System.out.println(arr[5]);
System.out.println(intArr[1][1]);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -