What is the difference between an int and an Integer in Java and C#?

前端 未结 26 1872
生来不讨喜
生来不讨喜 2020-11-22 12:00

I was reading More Joel on Software when I came across Joel Spolsky saying something about a particular type of programmer knowing the difference between an i

26条回答
  •  清歌不尽
    2020-11-22 12:20

    In Java int is a primitive data type while Integer is a Helper class, it is use to convert for one data type to other.

    For example:

    double doubleValue = 156.5d;
    Double doubleObject  = new Double(doubleValue);
    Byte myByteValue = doubleObject.byteValue ();
    String myStringValue = doubleObject.toString();
    

    Primitive data types are store the fastest available memory where the Helper class is complex and store in heep memory.

    reference from "David Gassner" Java Essential Training.

提交回复
热议问题