Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Static and non-Static methods
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
abogaida




PostPosted: Thu Apr 09, 2009 6:55 am   Post subject: Static and non-Static methods

What is the different between static and non-static methods?
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: 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.
matt271




PostPosted: 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
abogaida




PostPosted: Thu Apr 09, 2009 4:02 pm   Post subject: RE:Static and non-Static methods

thanks for the information Smile
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: