Comparing Performance of int and Integer

后端 未结 5 2088
天涯浪人
天涯浪人 2020-12-18 18:26

Which one is best in programming - int or Integer? Especially whenever both are doing the same task?

I am writing an appli

5条回答
  •  旧时难觅i
    2020-12-18 19:01

    As an alternative view.... perhaps you should use neither Integer nor int.

    If the value is really an object with behaviour - like say an amount of money, or a distance or something, then perhaps you should be using an object with behaviour.

    You can see more about this kind of thing here:

    http://www.time4tea.net/wiki/display/MAIN/Microtypes

    Although this may be "slower", the additional type safety will make the programming, testing and debugging of your system much easier & faster.

提交回复
热议问题