Popular Posts
DNS SERVER LIST Google 8.8.8.8 8.8.4.4 TWNIC 192.83.166.11 211.72.210.250 HiNet 168.95.1.1 168.95.192.1 Seednet 北區 DNS (台北, 桃園, 新竹, 宜蘭, 花蓮, 苗栗) 139.... write 語法: write at [/][<pos>][(<len>)] output 用法: write 'Bruce'. " 輸出常數 Bruce data CNAME(10) value... Regex (Regular Expression) tool Eclipse Regular Expression Tester Java正規表示式工具-Eclipse GUI介面 [Visual Studio 2010] 好用的 Regex 輔助工具
Stats
Create instance using Class
import java.lang.reflect.Constructor;

public class Case012 {

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub

        // General way to create a new instance
        // Case012 c = new Case012("dddd");

        Class c = Class.forName("sb.test.c010.Case012");

        Constructor constructor1 = c.getConstructor(String.class);
        constructor1.newInstance("test");

        Constructor constructor2 = c.getConstructor(int.class, int.class);
        constructor2.newInstance(10, 20);
    }

    public Case012(String s) {
        System.out.printf("Create instance with string parameter : %s", s);
        System.out.println();
    }

    public Case012(int x, int y) {
        System.out.println("Create instance with two int paramters.");
        System.out.printf("Sum of two number is : %d", x + y);
        System.out.println();
    }
}