Methods can return data to the code where they have been called from. A method can return a primitive value or an object reference, or it can return nothing if we use the void keyword as the return type. Let’s see an example of a void method:
方法参数用于接收传递给方法的变量值。调用方法时,必须严格按照参数的定义一一传递。例如: class Person { ... public void setNameAndAge (String name, int age) { ... } } 调用这个setNameAndAge()方法时,必须有两个参数,且第一个参数必须为String,第二个参数必须为int: