Jabber Jabber - 6 months ago 9x
Java Question

Can someone give an example method

I am new to java and am just practicing. I have this question and wondering if anyone can give me an example for this please.

Method that accepts a string parameter and returns a value that is the result of using string and/or character processing


Just take a look at the Doc:

The only required elements of a method declaration are the method's return type, name, a pair of parentheses, (), and a body between braces, {}.


public class Test {

    public static void main(String[] args) throws MyException {
        sayHello();  //method with no parameters
        sayThis("Hello World"); //method with string as parameter

    private static void sayThis(String msg) {
        System.out.println("Method with parameter:" + msg);

    private static void sayHello() {