Social Media

Static Binding – Compile Time

  • Compile time
  • private, final and static
  • Overloaded methods

In the example below the compile will resolve the overloaded method, and call the total(Integer integer) method

[sourcecode language=”java”] public class StaticBinding {
public static void main(String args[]) {
Number n = new Integer();

StaticBinding staticBinding = new StaticBinding();
staticBinding.total(n);
}

public void total(Number number) {
System.out.println("total(Number number));
}

public void total(Integer integer) {
System.out.println("total(Integer integer)");
}
}
[/sourcecode]

About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: