This function in constructor in java -


is different between 2 types?

public class myclass{ string name;  public myclass(string nn){ this.name = nn; name = nn; } } 

no, equivalent. useful explicit using this keyword because there might 2 variable same name different scope, this:

public class myclass {     string name;      public myclass(string name) {         name = name; // doesn't work         this.name = name;  // works.     } } 

but since not in situation, doesn't make difference.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -