I am working on understanding java compilation and I came across a question. Say we have a class like this
public class Ambiguity
{
static class G
{
void A()
{
System.out.println("Regular Method");
}
}
static class b
{
static void A()
{
System.out.println("Static Method");
}
}
public static void main(String[] args)
{
G b = new G();
b.A();
}
}
How does the compiler know the weather to call a method static void A()in class bor a regular method of an void A()object of btype G. Based on the tests, it calls a method b(type G) call , but I did not know if this is a standard procedure. In this situation, you can call the static method.
source
share