- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Static methods vs Instance methods in Java
In Java as we know that the behavior of any variable/method is defined by the keyword that is used in front of its declaration name. So one of the non-access modifiers is Static which can be used along with method as well as with variable.
Static methods as name states defined at the class level and could be accessed on the class name i.e no need of class object creation in order to access/call the static methods.
While on another hand if we do not uses the static keyword with variable/method than it belongs or categorized as instance method which is defined at instance level and need class object for their accessibility.
Also static methods exist as a single copy for a class while instance methods exist as multiple copies depending on the number of instances created for that particular class.
Static methods can't access instance methods/variables directly while instance methods can access static variables and static methods directly.