• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic method lookup  RSS feed

 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone explain what the dynamic method lookup is? or resources?
Thanks
 
Sat Nar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dynamic method lookup is the mechanism by which the call to an overridden function is resolved at run time rather than compile time.

Example :

public interface Factory
{
public void execute();
}

class A implements Factory
{
public void execute()
{
System.out.println("Executing A");
}
}

class B implements Factory
{
public void execute()
{
System.out.println("Executing B");
}
}

class Dispatch
{
public void main(String[] args)
{
A a = new A();
B b = new B();

Factory f;

f = (Factory)a;
a.execute();

f = (Factory)b;
b.execute();
}
}

Regards,
Sathya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!