This is something that we all take for granted, but the thought occurred to me today. Why can we do this?
package com.package
public class SomeOtherClass{
private ClassContainingList classContainingList = new ClassContainingList();
public void doStuff(){
SomeClass someClass = classContainingList.getList().get(0);
}
}
Assume that ClassContainingList and SomeClass are also in com.package and classContainingList.getList() returns a java.util.List.
In classContainingList.getList().get(0) we are now calling methods from the List interface without ever actually importing it.
How does Java "know" about the method without an import?