defining global constants
How do you define global constant in Java, ie. in C/C++ we use #define ?
Also, suppose I have created an arraylist/list called children, and I have the following classes, polar, black, grizzly. The question is will I be able to do the following:
polar child(...../*parameters*/);
children.add(child);
Thx
I wonder why you spent time looking for this forum and posting the question instead of reading some book or online tutorial?
There is NO such term as "global variable" in Java. Something similar is
static final int CONSTANT_INTEGER = 1;
static final float CONSTANT_FLOAT;
......
//in code:
CONSTANT_FLOAT = 1.45f;
but note that class variable can be initialized somewhere else.
As to
polar child(...../*parameters*/);
children.add(child);
- please, read something about Collections etc...
thx, and I have try to look for tutorial on these topics in the website, but I can't seem to find it in with the search function. If you can, can you show me the link?