Void in context

In this exercise


it tries to explain what void means in a method and says it means in returns nothing, but in the exercise it uses to help explain it has lines like this

public void bark()

wouldn’t that be considered to return a string with woof? What about this am I not understanding, am I misinterpreting the meaning of returning a value? Thanks.

Nothing is returned. The string is sent to the print buffer and then poof! It’s gone. A return would be tangible and still in play.

Thanks! So a return would be if it was getting a value like an int to store in a variable or something? I think that is the part that I am getting confused by.

Correct. It would different if we wrote,

    return "Woof!"


String dogSpeak = bark();

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.