System.在InputStream类的对象引用中是什么? [英] is System.in an object reference of InputStream class?

查看:145
本文介绍了System.在InputStream类的对象引用中是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

InputStream是一个Abstract类,那么我们如何访问System.in.此外int read()是InputStream类中的抽象方法,那么我们如何才能访问System.in.read()方法呢? read()是一种抽象方法. 像

InputStream is an Abstract class.Then how are we able to access System.in.And moreover int read() is an abstract method in InputStream class.Then how are we able to access System.in.read() method if read() is an abstract method. Like

int a=System.in.read();
System.out.println((char)a); 

推荐答案

我建议您阅读有关Java中抽象和继承方法的更多信息.

I suggest you to read more about abstraction and inheritance methods in Java.

如果扩展抽象类,则必须实现其抽象方法.这样,您可以为其提供一个实现,供使用者调用.

If you extend an abstract class, you have to implement its abstract methods. This way, you provide an implementation for it, which can be called by consumers.

System.in是扩展InputStream而不是直接扩展InputStream的类的实例.

System.in is an instance of a class which extends InputStream, not of InputStream directly.

这篇关于System.在InputStream类的对象引用中是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆