+ 2
What is static member?
Please explain it with an example
3 Respostas
+ 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
+ 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();
}
}
+ 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