Java 如何决定何时导入? [英] How does Java decide when to import?

查看:19
本文介绍了Java 如何决定何时导入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么Java不需要导入Integer、String等类,而需要导入其他类?

Why doesn't Java need to import classes like Integer, String, etc. while it needs to import other classes?

推荐答案

java.lang.* 有一个隐式导入.

来自 Java 规范:

编译单元自动访问其包中声明的所有类型,并自动导入预定义包java.lang中声明的所有公共类型.

A compilation unit automatically has access to all types declared in its package and also automatically imports all of the public types declared in the predefined package java.lang.

这篇关于Java 如何决定何时导入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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