导入java.util.*后使用entrySet()函数时找不到符号 [英] Cannot find symbol when using entrySet() function after import java.util.*

查看:64
本文介绍了导入java.util.*后使用entrySet()函数时找不到符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用函数 Map.entrySet().当我使用 import java.util.* 时,它提示找不到符号错误.但是,当我执行 import java.util.Map.Entry 时,它会编译."*"不应该包含 Map.Entry吗?

I am using a function Map.entrySet(). When I am using import java.util.* it gives cannot find symbol error. But, when I am doing import java.util.Map.Entry it compiles. Shouldn't "*" include Map.Entry?

我错过了什么吗?

使用import java.util.* 的底线使我找不到符号错误.对于相同的代码,导入 java.Map.Entry; 不会.为什么?

Bottom line using import java.util.* gives me cannot find symbol error. For the same code import java.Map.Entry; does not. Why?

谢谢.

推荐答案

星型导入用于导入包的所有类.当您指定

The star import is used for importing all classes of the package. When you specify

import java.util.*;

您将所有具有全名 java.util.< ClassName> 的类都视为导入的.

You are denoting that all classes that have full name java.util.<ClassName> are to be considered imported.

java.util.Map.Entry java.util.Map 类的内部类.子类的星级导入将是这样的

java.util.Map.Entry is an inner class of java.util.Map class. The star import for sub-classes will be something like this

import java.util.Map.*;

我不能说完全使用start导入是一种好习惯.大多数编码指南都建议避免这种情况.子类明星的导入通常不会在代码中出现.

I can't say that it is a good practice to use start imports at all. Most of coding guidelines recommend to avoid it. Sub-class star imports isn't something you usually will come across in the code.

这篇关于导入java.util.*后使用entrySet()函数时找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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