+ 2

What is static member?

Please explain it with an example

18th Nov 2021, 2:26 AM
Dipika😊
Dipika😊 - avatar
3 odpowiedzi
+ 4
Static member means it is directly a member of a class and can be called by writing the class name and the variable or method name
18th Nov 2021, 3:17 AM
Atul [Inactive]
+ 10
static members are those which belongs to the class and you can access these members without instantiating the class. public class MyClass { public static void sample(){ System.out.println("Hello"); } public static void main(String args[]){ MyClass.sample(); } }
21st Nov 2021, 3:37 PM
Vaibhav
Vaibhav - avatar
+ 4
A static member is bound to the class itself instead of objects of the class. Meaning, you can call a static member or use a static variable without creating an object of the class. The following code is a little example. The Sololearn Java course will give you more examples =) https://code.sololearn.com/c88xN9U4K0dK/?ref=app
18th Nov 2021, 2:44 AM
Rishi
Rishi - avatar