What does void do in java?

后端 未结 6 2005
孤城傲影
孤城傲影 2020-11-29 11:52

The return type—the data type of the value returned by the method, or void if the method does not return a value.

http://download.oracle

6条回答
  •  情深已故
    2020-11-29 12:18

    You mean the tellItLikeItIs method? Yes, you have to specify void to specify that the method doesn't return anything. All methods have to have a return type specified, even if it's void.

    It certainly doesn't return a string - look, there are no return statements anywhere. It's not really clear why you think it is returning a string. It's printing strings to the console, but that's not the same thing as returning one from the method.

提交回复
热议问题