In Java does anyone use short or byte?

前端 未结 11 889
挽巷
挽巷 2020-12-14 15:44

Apart from using (byte[]) in streaming I don\'t really see byte and short used much. On the other hand I have seen long used where the actual value is |100| and byte would b

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 16:11

    I would most often use the short and byte types when working with binary formats and DataInput/DataOutput instances. If the spec says the next value is an 8bit or 16bit value and there's no value in promoting them to int (perhaps they're bit flags), they are an obvious choice.

提交回复
热议问题