Void and return in Java - when to use

后端 未结 7 1918
予麋鹿
予麋鹿 2020-12-18 17:10

I have some \"confusion\" about void and return. In general, I understand void is used in methods without returning anything, and return is used in methods when I want to re

7条回答
  •  情话喂你
    2020-12-18 18:01

    you have function definition like this: -public(or private, etc)-lvl access. -static(or blank)to access that method without creating an instance of that object. -and void: you have noticed that any function that return something have that 'something's' data type included in definition (eg: returning int values, or strings). Now, when your function have no return, think at VOID like a placeholder for datatype(int,string, etc)

提交回复
热议问题