1

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.

1
  • Java doesn't have named arguments. Either you're using a bad course, or it is for a different language than Java. Commented Jul 25, 2020 at 8:13

1 Answer 1

1

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);
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.