Gowtham Raj
Gowtham Raj

Reputation: 11

Error:(7, 22) java: ')' expected when executing my code

I receive the following error:

Error:(7, 22) java: ')' expected when executing my code:

public class Main {

    public static void main(String[] args) {
        // write your code here
        myName( mName:"Gowtham");
    }

    public static void myName(String mName) {
        System.out.println(mName);
    }
}

This is the code I wanted to execute but it tells it has errors, learning it through some online courses.

Upvotes: 1

Views: 269

Answers (1)

Alex Leo
Alex Leo

Reputation: 2851

The error is here

myName( mName:"Gowtham");

Just write it as following:

public class Main {

    public static void main(String[] args) {
        // write your code here
        myName("Gowtham");
    }

    public static void myName(String mName) {
        System.out.println(mName);
    }
}

Upvotes: 1

Related Questions