gpt4 book ai didi

java - 将整数添加到 vector

转载 作者:行者123 更新时间:2023-12-04 05:28:41 24 4
gpt4 key购买 nike

很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center .




8年前关闭。




大家好,在阅读我们使用的输入数据流时

BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));

BufferedReader阅读流是如此好,为什么我们不能只使用
BufferedReader stdin=new BufferedReader(System.in);

为什么我们需要 InputStreamReader ??

最佳答案

BufferedReader 似乎是 Reader 类的包装类。使用 System.in 构造 BufferedReader 根本不是有效的语法。 BufferedReader 类的原因来自文档:

In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is therefore advisable to wrap a BufferedReader around any Reader whose read() operations may be costly, such as FileReaders and InputStreamReaders. For example,

BufferedReader in = new BufferedReader(new FileReader("foo.in"));

will buffer the input from the specified file. Without buffering, each invocation of read() or readLine() could cause bytes to be read from the file, converted into characters, and then returned, which can be very inefficient.

关于java - 将整数添加到 vector ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12889924/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com