| Author |
Method Variable in java
|
Nidhi Jain
Ranch Hand
Joined: Mar 26, 2006
Posts: 31
|
|
Hi, I have two doubt. one if have one method and inside that mathod i have one variable can we use method variable without intialize it? and second can method use class variable without intialize it value? wat happen in both cases? Thanks
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
You cannot use variables that have not been initialized. If you try, the compiler will give you an error message. However, class member variables are initialized implicitly if you don't initialize them yourself, whereas local variables (variables inside methods) are not - they must be initialized explicitly. For example:
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9950
|
|
|
the best way to learn this stuff is to try it out!!! write small, simple programs that do almost nothing (a "Hello, world!!" program would work for many cases), and see what happens!!! it's fast, easy, and you will learn it faster and remember it better if you do.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: Method Variable in java
|
|
|