Is there any sizeof-like method in Java?

后端 未结 15 1057
暗喜
暗喜 2020-11-27 15:03

Is there any built-in method in Java to find the size of any datatype? Is there any way to find size?

15条回答
  •  感情败类
    2020-11-27 15:35

    I decided to create an enum without following the standard Java conventions. Perhaps you like this.

    public enum sizeof {
        ;
        public static final int FLOAT = Float.SIZE / 8;
        public static final int INTEGER = Integer.SIZE / 8;
        public static final int DOUBLE = Double.SIZE / 8;
    }
    

提交回复
热议问题