Obviously since Path is an interface it cannot be instantiated by using the new keyword and so we use Path.get()
to create a path from a string. But what kind of object is this, it can't be a path object can it because Path is an interface, but when I call the .getClass().getCanonicalName()
method I get some cryptic "sun.nio.fs.WindowsPath"
response which doesn't answer anything since I can't instantiate this either
edit : after playing around with the runnable interface I found it is quite easy to use a method to create an implementation of an interface and therefore I would like to clarify my question somewhat. When you create an instance of an object that extends an interface you are creating an instance of that object e.g. An object from class Bar is a Bar object even if it extends the interface Foo. But say I write an implementation for an Interface Foo without writing a class that extends it ; my question is what kind of object is this?
public Interface Foo { public void doStuff();}
Then in main:
Foo foo1 = new Foo(){
public void doStuff(){
// code goes here
}
};
What kind of object is foo1?