#I don't understand the difference between void methods and methods that return values

3 messages · Page 1 of 1 (latest)

icy flame
#

So I'm doing mooc.fi and it's telling me that void methods don't return values and methods defined as variables do. Except I'm a little confused by this -- what does "return" mean in this context? What's the difference between:

  a = 3;
  }```
and
```public static int number() {
  return 3;
  }```
Also, why might someone choose one over the other?
pure axleBOT
#

This post has been reserved for your question.

Hey @icy flame! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.