Final Fantasy Forums
Go Back   Final Fantasy Forums > Final Fantasy Extreme Discussion Central > 1001001011
Final Fantasy Final Fantasy Forums Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

1001001011 Come to this forum to get technical help, or just discuss technology as a whole; computers, electronics, phones, and other accessories that make us drool.

Reply
 
LinkBack Thread Tools Display Modes
Old 04-14-2007, 02:52 PM   #1 (permalink)
Aibbie
La di da
 
Aibbie's Avatar
 
Join Date: Apr 2007
Age: 18
Posts: 314
Rep Power: 4 Aibbie is on a distinguished road
Send a message via MSN to Aibbie
Default Static?

For some odd reason, I took a computer programming course back in fall (I still don't understand why I did that since computers are more foreign to me than aliens) sadly the course exam is coming up, and there are quite a bit of information that I've forgotten...

Anyways, for those of you who remotely understand computer programming and Java, I'd be most grateful if you can tell me what the "static" key word is functioned as in a set of code.
__________________

"When you're dreaming with a broken heart, waking up is the hardest part..."
Aibbie is offline   Reply With Quote
Old 04-16-2007, 05:03 PM   #2 (permalink)
YopY
BOOM HEADSHOT!
 
YopY's Avatar
 
Join Date: Jan 2007
Age: 22
Posts: 299
Rep Power: 4 YopY is on a distinguished road
Default

A Static bit of information (i.e. a method / function or a field / variable / whatever) is basically accessible without having an instance of the class you've put it in. You can use it to put in data and/or methods that are accessible from anywhere, for example a counter that keeps track of the amount of instances of a class

Code:
class Pete {

private int aNumber;
static int instances;

public Pete( int num ) {
   aNumber = num;
   Pete. instances++;
}
}
, or a method that resets the counter

[code]

class Pete {

static void Reset() {
Pete.instances = 0;
}
}

Which is basically it. As far as I know, you can't declare variables or methods outside of a class (contrary to more old-school languages like C and/or PHP), so the Static keyword is the way to still be able to do stuff like that.

Look here for some more detailed information (or if the above is still too complex, ), for great justice.
__________________
YopY is offline   Reply With Quote
Old 04-16-2007, 05:30 PM   #3 (permalink)
Aibbie
La di da
 
Aibbie's Avatar
 
Join Date: Apr 2007
Age: 18
Posts: 314
Rep Power: 4 Aibbie is on a distinguished road
Send a message via MSN to Aibbie
Default

Ah I see, thank you very much.

Since the teacher is new and rather incompetent I've resolved to asking people and reading the textbook (*shudders*), and I must say your explanation is more straightforwards than the book's sad excuse for a definition...
__________________

"When you're dreaming with a broken heart, waking up is the hardest part..."
Aibbie is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:23 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0