[英]Cannot find symbol when using entrySet() function after import java.util.*
I am using a function Map.entrySet()
. 我正在使用Map.entrySet()
函数。 When I am using import java.util.*
it gives cannot find symbol error. 当我使用import java.util.*
它给出了找不到符号错误。 But, when I am doing import java.util.Map.Entry
it compiles. 但是,当我执行import java.util.Map.Entry
它会编译。 Shouldn't "*" include Map.Entry?
“ *”不应该包含Map.Entry?
Am I missing anything? 我有什么想念的吗?
Bottom line using import java.util.*
gives me cannot find symbol error. 使用import java.util.*
底线使我找不到符号错误。 For the same code import java.Map.Entry;
对于相同的代码,请导入java.Map.Entry;
does not. 才不是。 Why? 为什么?
Thank You. 谢谢。
The star import is used for importing all classes of the package. 星号导入用于导入包的所有类。 When you specify 当您指定
import java.util.*;
You are denoting that all classes that have full name java.util.<ClassName>
are to be considered imported. 您表示所有具有全名java.util.<ClassName>
都将被视为已导入。
java.util.Map.Entry
is an inner class of java.util.Map
class. java.util.Map.Entry
是java.util.Map
类的内部类。 The star import for sub-classes will be something like this 子类的星级导入将是这样的
import java.util.Map.*;
I can't say that it is a good practice to use start imports at all. 我不能说完全使用start导入是一个好习惯。 Most of coding guidelines recommend to avoid it. 大多数编码指南都建议避免这种情况。 Sub-class star imports isn't something you usually will come across in the code. 子类明星导入通常不会在代码中遇到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.