为什么我不能导入静态java.lang.System.out.println? [英] Why can't I import static java.lang.System.out.println?

查看:282
本文介绍了为什么我不能导入静态java.lang.System.out.println?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我可以导入静态java.lang.Math.abs时,我无法导入静态java.lang.System.out.println,这似乎很奇怪。这背后有什么原因,或者我做了一些我现在看不到的蠢事? (使用Eclipse。)

It seems strange that I can't import static java.lang.System.out.println, when I can import static java.lang.Math.abs. Is there some reason behind this or am I doing something really stupid that I don't see at the moment? (Using Eclipse.)

推荐答案

数学是一个类, abs 是一种静态方法。 System.out 是静态字段而不是类。所以它的 println 方法实际上不是静态方法,而是静态字段上的实例方法。

Math is a class, on which abs is a static method. System.out is a static field rather than a class. So its println method isn't actually a static method, but an instance method on a static field.

这篇关于为什么我不能导入静态java.lang.System.out.println?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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