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

  • 相关阅读:
    CF869E The Untended Antiquity 解题报告
    Walk 解题报告
    CF911F Tree Destruction 解题报告
    P4397 [JLOI2014]聪明的燕姿
    洛谷 P2329 [SCOI2005]栅栏 解题报告
    洛谷 P3747 [六省联考2017]相逢是问候 解题报告
    set-erase
    set-empty
    set-empty
    set-end
  • 原文地址:https://www.cnblogs.com/aomi/p/3172490.html
Copyright © 2011-2022 走看看