+ 1
Use of this keyword in Java
What is the use of this keyword when we call a static function without creating an object?
3 Respostas
+ 2
static - 'Class members' (variables, methods) can be referenced by
ClassName.memberName
similar like non-static by
objectName.memberName or
this.memberName (inside class definition)
+ 1
public class Program {
static int x;
static void method(int x){
Program.x = x;
}
public static void main(String[] args) {
Program.method(100);
System.out.println( Program.x );
} }
+ 1
zemiak Can You Please explain?
Specially what is the use of classname.variablename?