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
Post a Comment