英文:
"Abstraction" in the context of I/O system
问题
我正在阅读《Java入门指南,第八版》这本书,特别是第10章,关于使用I/O。我读到了这句话:“I/O流是一种在产生信息或消耗信息之间进行抽象的方式”。我了解编程背景下“抽象”的概念,但这里的“抽象”是什么意思?我不明白它是什么意思!
英文:
I was reading <b>Java A Beginner’s Guide, Eighth Edition</b> book specifically in Chapter 10, Using I/O, and I read this phrase <b>"An I/O stream is an abstraction that either produces or consumes information"</b> I know about abstraction in the context of programming, but what is the meaning of the word abstraction here? I did not understand what it means!
答案1
得分: 2
在这里,“抽象”一词是在编程上下文中使用的。Java的java.io.InputStream
和java.io.OutputStream
是用于抽象底层IO技术的接口。当使用这样的流实例时,您无需关心数据的确切来源,只需使用Stream接口。实现可以是内存流、磁盘上的文件、网络请求、音频流等。
当您(或您的程序)使用输入流时,只需调用read
,而不必担心底层技术。对于输出流,只需调用write
即可。
英文:
The word abstraction here is used in the context of programming. Java's java.io.InputStream
and java.io.OutputStream
are interfaces which abstract away the underlying IO technology. When consuming such a stream instance, you do not have to care about where exactly the data comes from, you only use the Stream interface. The implementation could be an in-memory stream, a file on disk, a network request, an audio stream, etc.
When you (or your program) works with an input stream, it simply needs to call read
, without worrying about the underlying technology. With output streams this becomes a simple call to write
.
答案2
得分: 0
例如,抽象化被用于电话上的按钮。你使用按钮来进行活动,但你不知道它是如何工作的。它只是完成任务。
在这里,它意味着你可以使用I/O流来生产或消费信息,而不用担心它是如何工作的。你只需使用它已经编写好的方法。
英文:
for example abstraction is used on a button on telephone. You use button to do activity, but you dont know how it works. It just do the job.
Here, it means you can use I/O stream for produce or consume information without wondering how it works. You just can use its already written methods.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论