View RSS Feed

My Java Tips

  1. Static/Non static methods - Example

    by , 06-02-2011 at 07:12 PM (My Java Tips)
    I will present an example to show the difference between static and non-static methods.

    Go through the example below:

    Java Code:
    public abstract class AbstractExample {
    
       public static void foo() {
          System.out.println("Static foo called.");
       }
    
       public void bar() {
          System.out.println("Non-static bar called.");
       }
    }
    
    public class AbstractCaller extends AbstractExample {
    ...
    Categories
    Java SE