public static int convertToSeconds(int hour){
public static void main(String[] args) {
Hi! Why first is public static INT and second has to be VOID to run? Why it is not INT too or why both can not be void?
Hi! Why first is public static INT and second has to be VOID to run? Why it is not INT too or why both can not be void?
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Jimmy Phan
6 November 2019, 04:47
int, String, double, boolean, etc... are written in methods to tell you what you are getting back. (returning a value).
public static int (please do an action and return me an integer)
public static String (please do an action and return me an a String)
meanwhile the word void means : "Hey! I don't want anything back from this method".
+2
Maja Mal
11 November 2019, 15:26
Thank you! love this style of explaining :D <3
0
Potato Sheep
6 November 2019, 03:40
void means it doesn't return anything data. It just perform specific task or output some result to the client side. Declaring a method with return type tells the compiler that the method should return a data based on the return type that was specified. Like
+3