Fiveable
Fiveable

Non-Static Methods

Definition

Non-static methods are functions or procedures that belong to an object and can only be accessed through an instance of the class. They can modify the state of an object and are not associated with a specific class.

Analogy

Think of non-static methods as actions performed by a person. Just like how each person has their own unique set of abilities and can perform different tasks, objects in a class have their own non-static methods that define what they can do.

Related terms

Dot Notation: Dot notation is used to access non-static methods by using the name of the object followed by a dot (.) and then the method name. It allows you to call specific actions on an object.

System.out.println: System.out.println is a commonly used non-static method in Java that prints text or values to the console. It is often used for debugging purposes or displaying information to users.

Static Methods: In contrast to non-static methods, static methods belong to a class itself rather than an instance of the class. They can be called directly without creating an object and cannot modify the state of an object.

"Non-Static Methods" appears in:



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.