Answer the question
In order to leave comments, you need to log in
Why are NOT void methods needed?
I just started learning programming, so I apologize in advance for stupid questions.
Let's take 2 scripts, both have the same result, BUT one is made using int
public class qwert {
public static int xxx(){
int x = 10+11;
return x;
}
public static void main(String[] args) {
System.out.println(xxx());
}
}
public class qwert1 {
public static void xxx(){
int x = 10+11;
System.out.println(x);
}
public static void main(String[] args) {
xxx();
}
}
Answer the question
In order to leave comments, you need to log in
Maybe in order to pass values to others, no?
Give me back a value from xxx() so I can pass it to another method.
For example, in the yyy(int value)
method Call the yyy() method and pass it the value that you get from xxx() without an additional variable
Or take and get the data of the LocalDateTime.now() method - think, this is also a method and it void
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question