static vs. non-static method

C

Chris Smith

Ryan said:
What is the difference?

A non-static method does something to a specific object. A static
method is just a piece of code, and it's only put into a class as a
convenient place to put it. Static methods don't work with any specific
object.

As a result, non-static methods can do things that static methods can't
-- for example, they can access the state or call other non-static
methods of the object they working with. These things aren't possible
in a static method, because there *is* no object that they are working
with.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
K

KiLVaiDeN

Ryan said:
What is the difference?

static members = Class defined, means you can use the methods / attributes
with the class name directly, and they are shared by all objects of that
class.

instance members = are defined for each object, can manipulate object own
attributes, and there is a copy of each of these members for each object
instanciated.

Hope I was clear enough, good luck

K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top