Hai. I am a beginner in Java. Is there any difference between a variable and a data member? If so what are the differences?
Joined: Mar 18, 2004
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.
Joined: Feb 07, 2002
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.