Feeds:
文章
留言

Archive for 四月 18th, 2014

import static java.lang.System.out;
import java.lang.reflect.Field;

public class Test {
    publicstaticvoid main(String[] args) {
        for (final Field field :Double.class.getDeclaredFields()){
           try {
                if(field.getName().equals("BYTES")){
                    out.println(field.get(null)); // Double = 8 bytes
                }
           }catch (IllegalAccessException illegalAccess){
                out.println("ERROR: Unable to reflect on field \"BYTES\"");
           }
        }
    }
}

參考資料
[1]http://www.javacodegeeks.com/2014/04/programmatic-access-to-sizes-of-java-primitive-types.html

Read Full Post »