So, say I have the following enum declaration:
public class WatchService implements Runnable
{
private State state;
private enum State
{
FINDING_MANIFEST, FINDING_FILES, SENDING_FILES, WAITING_TO_FINISH
};
// other stuff
}
Now, say I have the following abstract class:
public abstract class MyOtherAbstractClass extends MyAbstractClass
{
// other stuff
private WatchService watchService;
// other stuff
}
Now, say I have the following class that extends the aforementioned abstract class:
public class MyClass extends MyOtherAbstractClass
{
// other stuff
}
If I have several instances of MyClass, will they all share the current State value? For instance, if one instance declares state = State.FINDING_MANIFEST;, will all instances have the current state of FINDING_MANIFEST?
I hope this makes sense..
If “state” is static, then yes. Otherwise no.
Change to:
This makes
stateshared among all instances of your class.