Why is that?
Because Main()
is static.
If Main()
was an instance method, and you had called Main()
on an instance of myClass
(e.g., new myClass
), then doThis()
could also be an instance method. Or, if your static Main()
created an instance of myClass
, it could call doThis()
on that instance.
When I develop some basic things in Android, I never have to use the static keyword.
That is because your entry points in Android tend to be instance methods on components (e.g., onCreate()
of an Activity
.
1
solved Android vs Java causing some confusion for me when creating methods