How is the dot allowed in this interface name, I cannot create another class/interface name with a dot in the name.
Asked
Active
Viewed 159 times
0
-
7Because it´s an inner interface of the `Map` `interface` which you are accessing. – SomeJavaGuy Jul 07 '16 at 12:46
-
A link for reference purposes https://docs.oracle.com/javase/8/docs/api/java/util/Map.Entry.html. There is a discussion on it here -> http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class – Rian O'Dwyer Jul 07 '16 at 12:48
-
1@KevinEsche Actually it's an interface ;) – vikingsteve Jul 07 '16 at 12:49
-
@vikingsteve yeah, corrected it for the correctness ;) – SomeJavaGuy Jul 07 '16 at 12:52
-
Ah, this was a stupid question...happens :) – Puneet Feb 08 '17 at 19:52
3 Answers
5
It's because Entry
is a nested interface within the Map
interface. You can create something similar if you want:
class MyClass {
static class Nested { }
public static void main(String[] args) {
MyClass.Nested n = new MyClass.Nested();
}
}
Or to answer your question more directly:
class MyClass {
static class MyEntry implements Map.Entry { }
public static void main(String[] args) {
Map.Entry n = new MyEntry();
}
interface Map {
interface Entry {}
}
}

assylias
- 321,522
- 82
- 660
- 783
1
As Kevin Esche commented, when creating an inner class, it's fully qualified name would become foo.bar.Outer.Inner
.

Kayaman
- 72,141
- 5
- 83
- 121
1
The Entry interface is declared in the Map interface. It's an inner interface. So in order to use it, we have to make a reference to Map class, hence the Map.Entry.

Zava
- 400
- 3
- 16
-
1Of course it's a public interface, otherwise you couldn't refer to it from another class. All members of an interface are automatically `public`, and `Map` is an interface, and `Entry` is a member of the interface `Map` so it's `public` too. – Erwin Bolwidt Jul 07 '16 at 13:22