aspose file tools*
The moose likes Beginning Java and the fly likes about local variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about local variable" Watch "about local variable" New topic
Author

about local variable

chun-ju Lin
Greenhorn

Joined: Feb 18, 2004
Posts: 6
Could someone tell me the difference between instance ,static and local variable?I only know that static variable comes with class and instance variable comes with object,but how about local variable?In what situation should I use local variable?
Sorry ,my English is very poor.
Ben Buchli
Ranch Hand

Joined: Mar 26, 2004
Posts: 83
hey,
a local variable is simply a variable within a method.
eg:
public void myMethod()
{
int n = 2;
//do something
}
so in this case the integer n is a local variable. You have to be careful with local variables, since they get deallocated from memory (sometime) after the method is executed. This means you can use local variables only within the method where they occur.
hope that helps.
ben
Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
Hello chun-ju Lin,

hope this helps
Davy


How simple does it have to be???
chun-ju Lin
Greenhorn

Joined: Feb 18, 2004
Posts: 6
I get the point,thank you for help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about local variable