| Author |
Isn't this contradictory ?
|
Netty poestel
Ranch Hand
Joined: Sep 20, 2004
Posts: 131
|
|
Page 1 of section[4.5] Marcus Green tutorial states:- "Essentially a class level variable will always be assigned a default value and a member variable (one contained within a method) will not be assigned any default value. " but "Certified Programmer & Developer for Java 2 Study Guide...by Kathy Sierra and Bates " states on page 33[1st chapter- Language fundamentals]:- Instance variables[ also called as member variables] are variables defined at the class level. Isn't this contradictory ?
|
 |
Jay Pawar
Ranch Hand
Joined: Aug 27, 2004
Posts: 411
|
|
Netty, Here are my views...
"Essentially a class level variable will always be assigned a default value and a member variable (one contained within a method) will not be assigned any default value. "
I wouldn't call member variable which is within a method. Variables within a method are called local variables and they need to be initialized before you use them. I perfectly agree with Kathy & Bert's terminology for member variables
|
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
|
 |
Jay Pawar
Ranch Hand
Joined: Aug 27, 2004
Posts: 411
|
|
Typo... I meant to say I wouldn't call a variable which is within a method as MEMBER variable. I believe it's a local variable
|
 |
Colin Fletcher
Ranch Hand
Joined: Sep 10, 2004
Posts: 200
|
|
There is a difference in termanology here. Instance Variables = member variables = class level variable local variable = METHOD variables = are defined within a method. From the code snippet above, you can see the userName variable is an instance variable or a member variable. The aVariable variable in doSomething is a method variable. Hope this helps
|
SCJP 1.4 SCWCD 1.4
|
 |
Jay Pawar
Ranch Hand
Joined: Aug 27, 2004
Posts: 411
|
|
Netty, I would appreciate if you could give me a link to Marcus Green tutorial ? Thanks in advance
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
Just as my own nitpick, be careful when you refer to "class-level" variables. When someone says "class-level" to me, I immediately think static variable. The terminology I use is like this, and usually seems to be appropriate: Local Variable - A variable defined within a method Instance Variable / Member Variable - A non-static variable declared within a class Class Variable / Static variable - A static variable declared within a class
|
SCJP Tipline, etc.
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
Originally posted by Jay Pawar: Netty, I would appreciate if you could give me a link to Marcus Green tutorial ? Thanks in advance
Marcus' Java Certification HeadQuarters (JCHQ) I started out there before I came over to JavaRanch. Marcus has helped a lot towards my SCJP 1.4 - especially the Question Of The Day
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Netty poestel
Ranch Hand
Joined: Sep 20, 2004
Posts: 131
|
|
Marcus tutorial page URL [Objective 5, Unassigned variables]:- http://www.jchq.net/certkey/0405certkey.htm and thx. all for all the feedbacks.
|
 |
 |
|
|
subject: Isn't this contradictory ?
|
|
|