| | |
what is the diffarance between object and varible
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
A variable is a symbol denoting a quantity or symbolic representation. A variable often represents an unknown quantity that has the potential to change.
An object is an individual unit of run-time data storage that is used as the basic building block of programs. These objects act on each other, as opposed to a traditional view in which a program may be seen as a collection of functions, or simply as a list of instructions to the computer. Each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent little machine or actor with a distinct role or responsibility.
Oh, and this was easy to find by searching Wikipedia.
An object is an individual unit of run-time data storage that is used as the basic building block of programs. These objects act on each other, as opposed to a traditional view in which a program may be seen as a collection of functions, or simply as a list of instructions to the computer. Each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent little machine or actor with a distinct role or responsibility.
Oh, and this was easy to find by searching Wikipedia.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
And when it comes to Java a variable is NEVER an object.
A variable (either a static or instance data member, technically) is always either a primitive or a reference to an object on the heap, never that object itself.
A variable (either a static or instance data member, technically) is always either a primitive or a reference to an object on the heap, never that object itself.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
An object variable's value is the given object's address in the dynamic storage area. A normal (or primitive type) variable itself has a value.
Example:
Output would be:
(Some memory address)
3
Note : This wouldnt be the case if a toString() method is available in Object, but the default implementation in Object prints the memory address in Dynamic Storage.
Example:
Object c;
c = new Object();
int a = 3;
System.out.println(c);
System.out.println(a);
Output would be:
(Some memory address)
3
Note : This wouldnt be the case if a toString() method is available in Object, but the default implementation in Object prints the memory address in Dynamic Storage.
that's incorrect. The toString() method for an object can print anything, depending on what the person implementing the method decided on.
In the case of Object (and thus by default) it prints the class name followed by the hashCode of the object instance, not its memory address.
In the case of Object (and thus by default) it prints the class name followed by the hashCode of the object instance, not its memory address.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- Object-Oriented Programming (C++)
- infected, embedded object. (Viruses, Spyware and other Nasties)
- Print Object hierarchy (C)
Other Threads in the Java Forum
- Previous Thread: java constructor..!
- Next Thread: Java taking over comoputer
Views: 1310 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application apps arguments array arrays automation binary bluetooth businessintelligence card chat class classes client code collision component crashcourse database detection draw eclipse error event exception file fractal free game gis givemetehcodez graphics gui helpwithhomework html ide image input integer integration j2me java javadoc javafx javaprojects jmf jni jpanel julia jvm linux list loop machine map method methods migrate mobile netbeans newbie nls number object oracle os physics print problem program programming project radio recursion remote scanner screen security server set size sms socket sort sql string swing test textfield threads time transfer tree trolltech utility windows






