Skip to content

Instantly share code, notes, and snippets.

@netojoaobatista
Created January 9, 2013 03:08
Show Gist options
  • Save netojoaobatista/4490247 to your computer and use it in GitHub Desktop.
Save netojoaobatista/4490247 to your computer and use it in GitHub Desktop.
package visibility;
public class Sample {
public static void main(String[] args) {
final User user = new User("Neto");
User.changePrivateName(user, "João Batista Neto");
user.showPrivateName(); // João Batista Neto
}
}
package visibility;
public class User {
private String privateName;
public User(String name) {
privateName = name;
}
public static void changePrivateName(User user, String name) {
user.privateName = name;
}
public void showPrivateName() {
System.out.println(privateName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment