0
Difference b/w return 1 , return 0 and return -1 ?????
3 ответов
+ 3
Return 0 means that your program executed without errors and you don't have to return it explicitly, because that'll happen automatically when main terminates.
Return 1 means that your program had an error.
+ 2
No difference at all.
but we generally write return 0 to tell the is that there was no error or the program ran successfully.
you can write return 123,return 375, return anything.
+ 1
These are different values which your function returns. It is your decision which values your functions return and how other functions react on these returned values.
You can use it as error codes, if you don't want or cannot use exceptions.
Also Java doesn't have a requirement that every function must return something.