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

  • 相关阅读:
    When You Get Troubles
    CentOS 6.8升级到7+
    Tomcat服务器搭建
    Percona Server 安装
    VirtualBox中如何使虚拟机能够上网?
    CentOS
    xen安装
    SSH免密码设置
    打造绿色版的RobotFramework
    零散知识记录-Jira的安装
  • 原文地址:https://www.cnblogs.com/aomi/p/3172490.html
Copyright © 2011-2022 走看看