In the following: public static void main(String[] args) { System.out.println("Something here...") } "void" indicates that this method will peform a task (displaying a line of text), but doesn't return any information when it completes the task. Well, wouldn't the string be information that is returned? I am confused.
this method will peform a task (displaying a line of text), but doesn't return any information when it completes the task
in this case, main does not return anything when it's done. like you said, this method DOES something (printing the line). AFTER THAT, it doesn't return anything. In C, your main method could return a value to the operating system. This could be written/used to see if the program exited "normally" or "abnormally". I've never seen a main() in Java that did return something, but i'm not saying you can't. does that help?
Never ascribe to malice that which can be adequately explained by stupidity.
Hi Ken, When talking about computers, you have to be creful to define your terms carefully. "returned" has a very specific meaning: it means that the data is available to whatever code calls the method, like
Here "substring" is a method declared to return type "String", and we see how this code calls substring and gets the returned information and puts it in a variable "returnedInformation", which gets the value "Hello". Now in your example, the "information" is displayed to the screen; if some other code invoked your main() method, it would not have access to what had been displayed. Thus this method returns nothing. Does this answer your question?
Okay! So, the method does something in "itself" but doesn't produce a variable that can be used by another class or method? So, in layman's terms: I think of something in my head but, because it's "void", I don't let anyone know what that thought is? Thanks for the help! Ken
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.