zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    SpringBoot处理跨域的四种方式
    centos部署nextcloud
    nginx反向代理时配置访问密码
    java对redis的基本操作
    springboot使用redis
    Linux安装redis
    centos安装php7.2环境 (亲测可用)
    linux下后台启动springboot项目
    全局加token
    web移动端浮层滚动阻止window窗体滚动JS/CSS处理
  • 原文地址:https://www.cnblogs.com/aomi/p/3172490.html
Copyright © 2011-2022 走看看