+ 2
Anyone can explain why. ' this '. keyword is used in java briefly.What errors may occur if we don't use this where it is requir
please answer me..
6 Réponses
+ 3
this is required when
-function returns object
-we process two or more objects
-when parameter name is same as data members name
+ 2
it depends on you what you wants to do...like
class A
{
int a;
void show(int a)
{
this.a=a;
}
}
here,method variable name and class variable name is same. so if i give 5. local variable a=5 will be,now if you want to save the value in class variable then you have to write this.a=a;
S0..here variable name is same that is why i used this. if the variable name is different then you don't have to use. Now you may ask..why same name?? because if you use different name for different purpose.. there will be many variable name which developer don't want....
there are other use of THIS also
+ 1
it not give any error
+ 1
thank sir
+ 1
what is the use of listener in event handling?
0
Actionlistener...when you put a value and Enter..it listen your action