Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static methods and variables

I do know that in java static methods can only use static variables and static methods and but non static methods can use non static variables and methods. is there any explanation why static methods can only access static variables/methods? and cannot access non static methods and variables?

like image 427
KyelJmD Avatar asked Dec 01 '25 08:12

KyelJmD


1 Answers

to access non-static methods/fields, you require an instance of the class.

like image 156
mre Avatar answered Dec 05 '25 05:12

mre



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!