Methods from classes and objects question. [SOLVED]
Trying to understand better the difference between calling methods from objects and classes.
For objects, you need to create an instance of the object before you call a method from it.
For classes, you can simply call the method from that class as long as it's available to you such as when you use import statements.
Now if thats even a correct understanding. Why even make objects if they are the exact same as a class. WHy not just keep using the classes methods and variables. Or is that true in most simple cases and thats whats practiced normally?
Not even sure I understand what I am trying to figure out concerning this but maybe with a little prodding I can move into the right direction.
Re: Methods from classes and objects question.
You cannot use methods from classes, not all of them anyway. you can only invoke static methods (Methods that doesn't depend on the class attributes.
for example, the class Rectangle has a method called contains(int x,int y). you cannot use this method unless you create an instance of this class (Object). When you instantiate class Rectangle you don't have to set width of height properties instantly, you can dynamically modify the content of the object. therefore the result of this method doesn't have to be a constant
Re: Methods from classes and objects question.
thanks for clearing that up a bit.