The term static
means that the method is available at the class level, and therefore does not require the object to be created before it is called.
Since writeNumbers
was called from a method that itself was static
, it can only call other static methods, unless it creates an instance of a new DisplayClass
object using something like:
DisplayClass displayClass = new DisplayClass();
only after this object has been created can non-static methods be called, for example:
displayClass.nonStaticMethod();
source share