Computer Science Canada

Static and non-Static methods

Author:  abogaida [ Thu Apr 09, 2009 6:55 am ]
Post subject:  Static and non-Static methods

What is the different between static and non-static methods?

Author:  [Gandalf] [ Thu Apr 09, 2009 9:19 am ]
Post subject:  RE:Static and non-Static methods

Non static members belong to instances of a class, while static members belong to the class itself. For more information, read wtd's Introduction to Java.

Author:  matt271 [ Thu Apr 09, 2009 3:01 pm ]
Post subject:  Re: Static and non-Static methods

say u have:

Java:
public class SomeClass {
 public static void someStaticMethod() {
  System.out.println("this is a static method");
 }

 public void someMethod() {
  System.out.println("this is not a static method");
 }
}


then you would call them like this:

Java:
SomeClass.someStaticMethod();

SomeClass blah = new SomeClass();
blah.someMethod();


Very Happy

Author:  abogaida [ Thu Apr 09, 2009 4:02 pm ]
Post subject:  RE:Static and non-Static methods

thanks for the information Smile


: