Public Void vs Private int?

posted Jan 13, 2015, 8:54 AM by Jon Hamlin
What does it mean when we see these terms at the start of a Java method?

example:   public void setName (String newName)

public means that the method is visible and can be called from other objects of other types. Other alternatives are private, protected, package and package-private. See here for more details.

void means that the method has no return value. If the method returned an int you would write int instead of void


Comments