Monday, 26 August 2013

What is the difference between String. and String.this. ?

What is the difference between String. and String.this. ?

I'll get straight to the point. Im still learning a bit of syntax and want
to know what the difference between this code is
CODE A:
public class Buttonz extends JButton{
public Buttonz(){
setText(new String(String.valueOf(i)));
}
}
Please ignore the fact that i is undeclared, that is not where I am lost.
CODE B:
public class Buttonz extends JButton{
public Buttonz(){
setText(new String(String.this.charAt(i)));
}
}
What I don't yet understand is what the difference is in typing
String.this and String.
I was under the assumption that when I use the dot operator on a class I
am accessing it's static methods(and/or variables if they're not hidden).
I have studied this a little bit and have concluded that when using
String. I am accessing String static methods.. but when using String.this.
I'm accessing the methods that my class Buttonz is extending.
Is this correct?
I apologize if I am right and are wasting time. I need to be sure to move
on. Thank you.

No comments:

Post a Comment