Why are there so many types of number in Java when long and double work every time?

后端 未结 3 1775
遥遥无期
遥遥无期 2021-01-24 07:34

Now I have been trying to learn Java Programming, I want to know why do we use things like Float, short, and int when we could be just be

3条回答
  •  离开以前
    2021-01-24 07:43

    If you know the bounds of the data you're trying to hold then it makes sense to use the smallest possible primitive data type that can hold it. This is going to always be more memory efficient than allocating more memory than you need.

提交回复
热议问题