java io读书笔记(3)数值类型的数据

input stream读取字节;out stream写入字节。Readers读取字符而Writers写入字符。因此,如果我们想理解input和output,我们首先就要明白

java如何处理字节,整数,字符以及其他数据类型。以及这些类型之间如何相互转换。

 

1)整数数据(Integer Data)

java中,基础的integer数据类型是int,4字节。long是8字节。short是2字节。

bytes,在java中用的特别多。尤其在io中,用的更多。一个byte是8位的。

在java内部,是没有byte和short类型的,当你写下42或者24000时,java内存是存储为int,而不是byte和short。哪怕是作为赋值时,也是这么处理的,比如:

byte b = 42; short s = 24000;

在这里,编译器是进行专门的assignment conversion

For these reasons, working directly with byte variables is inconvenient at best. Many of the methods in the stream classes are documented as reading or writing bytes. However, what they really return or accept as arguments are ints in the range of an unsigned byte (0255). This does not match any Java primitive data type. These ints are then converted into bytes internally.

 

2) Conversions and Casts

转载于:https://www.cnblogs.com/aomi/p/3172490.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值