Will using longs instead of ints benefit in 64bit java

前端 未结 3 653
孤街浪徒
孤街浪徒 2020-12-03 08:08

In a 64 bit VM, will using longs instead of ints do any better in terms of performance given that longs are 64 bits in java and hence pulli

3条回答
  •  猫巷女王i
    2020-12-03 08:16

    I always go with use the right datatype based on your problem domain.

    What I mean by this is if you need 64 bit long then use a 64bit long, but if you don't need a 64 bit long then use an int.

    Using 32 bits on a 64 bit platform is not expensive, and it makes no sense to do a comparison based on performance.

    To me this doesn't look right:

    for(long l = 0; l<100; l++)
     //SendToTheMoon(l);
    

    And SendToTheMoon has nothing to do with it.

提交回复
热议问题