java中的Class和可变参数

package javase;

import java.util.ArrayList;
import java.util.List;

public class Tool {

	public static Object copy(Object object) throws Exception {
		// 得到对象的类型信息
		Class cla = object.getClass();
		System.out.println(cla.getName());
		List list = new ArrayList();
		String[] strings = new String[] {};
		Class[] cl = new Class[] {};
		Class[] c = new Class[] {};
		cla.getConstructor(new Class[] {});
		Class cl2 = Integer.class;
		Class cl3 = Double.class;
		Class cl4 = Integer.class;
		return null;
	}

	public static void main(String[] args) throws Exception {
		copy(new Son());
		test("abc");
		test();
		// test(null);
		test("123", "hello");
		test(new String[] {});
		test(new String[] { "6688", "ok", "go" });
		List list = new ArrayList();
		String[] array = (String[]) list.toArray(new String[0]);
		test(array);
		String[] array2 = list.toArray(new String[0]);
		test(array2);
	}

	public static void test(String... strings) {
		System.out.println("----------------------------------");
		for (int index = 0; index < strings.length; index++) {
			System.out.println(strings[index]);
		}
		System.out.println("----------------------------------");
		
	}

}

java中的Class和可变参数_第1张图片java中的Class和可变参数_第2张图片java中的Class和可变参数_第3张图片

你可能感兴趣的:(java,Class,可变参数)