File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Difference between a variable and data member Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between a variable and data member" Watch "Difference between a variable and data member" New topic

Difference between a variable and data member

Vallabhaneni Suresh Kumar
Ranch Hand

Joined: Mar 01, 2004
Posts: 68
I am a beginner in Java. Is there any difference between a variable and a data member? If so what are the differences?
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
What is "Data Member"? Are you talking about the Attribute of a class?

These are different Variable can be of Class Level or Method level but Attribute of a class is class level.
Elouise Kivineva
Ranch Hand

Joined: Feb 07, 2002
Posts: 154
A variable is something referred to by a reference, such as int age (an integer named age). You can set a variable's value and reset it if the variable is not declared to be final. Declaring a final variable daysInAWeek = 7 makes for clearer code than just using the numer 7. A variable can be a primitive or an object reference.

Member data is/are variable(s) that belong to an object. A cat object for instance could have member data such as a string color and int age. Each cat object can then store, maintain and provide upon request its own information regarding its color and age.

See also Cup Size, a story about variables:
I agree. Here's the link:
subject: Difference between a variable and data member
jQuery in Action, 3rd edition