I am completely new to Java and came across a question that how java compiler creates object of one class in another class. For example :
I have class A as below :
class A{}
I have class B with main method :
class B {
public static void main(String[] args){
A a = new A();
System.out.println(a);
}
}
Here is the question: I wrote class A in one separate txt file and class B in another txt file. When I compile "Class B" How compiler knows that "class A" exists since there is no trace of class A in class B. We are not giving path of Class A and we are not not giving any clue that class A exists. But how java compiler knows and create object for Class A in class B. This might be a silly question but it is not letting me to proceed further without an answer. Thanks in advance.