what is the diffarance between object and varible

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2006
Posts: 5
Reputation: mrwan is an unknown quantity at this point 
Solved Threads: 0
mrwan mrwan is offline Offline
Newbie Poster

what is the diffarance between object and varible

 
0
  #1
Oct 5th, 2006
what is the diffarance between object and variable
Last edited by mrwan; Oct 5th, 2006 at 11:09 am.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: what is the diffarance between object and varible

 
0
  #2
Oct 5th, 2006
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.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: what is the diffarance between object and varible

 
0
  #3
Oct 5th, 2006
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 89
Reputation: TylerSBreton is an unknown quantity at this point 
Solved Threads: 3
TylerSBreton's Avatar
TylerSBreton TylerSBreton is offline Offline
Junior Poster in Training

Re: what is the diffarance between object and varible

 
0
  #4
Oct 7th, 2006
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:


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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: what is the diffarance between object and varible

 
0
  #5
Oct 8th, 2006
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 1310 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC