Hi guys,
I'm new to Java programming and I just read a few chapters of the textbook my instructor assigned. I'm a little confused about some statement usage:
I wrote a class containing 2 methods look like this:
public void method-name()
{
System.out.println("Hello");
}
AND
public String method-name()
{
return "Hello";
}
After compiling, I created an object of this class. It turns out I got the same result when I call those methods to this object I just created. However these are two types of methods which are procedure and function respectively,so what is the difference between the usage of them?
Why can I still get an string-like result using the method with "void" specified? Shouldn't that return no value?
and how can I get rid of the double quotation marks around the words with return statement?
thank you very much!
I'm new to Java programming and I just read a few chapters of the textbook my instructor assigned. I'm a little confused about some statement usage:
I wrote a class containing 2 methods look like this:
public void method-name()
{
System.out.println("Hello");
}
AND
public String method-name()
{
return "Hello";
}
After compiling, I created an object of this class. It turns out I got the same result when I call those methods to this object I just created. However these are two types of methods which are procedure and function respectively,so what is the difference between the usage of them?
Why can I still get an string-like result using the method with "void" specified? Shouldn't that return no value?
and how can I get rid of the double quotation marks around the words with return statement?
thank you very much!