Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

What is the issue here?

class UserInput {

  public void name() {

    System.out.println("This is a test.");

  }

}

public class MyClass {

  UserInput input = new UserInput();

  input.name();

}

This is throwing error:
 

<identifier> expected

   input.name();

1 Answer

0 votes
by (13.1k points)

You can try this:

public class MyClass {

    public static void main(String[] args) {

        UserInput input = new UserInput();

        input.name();

    }

}

Want to learn Java? Check out the Java certification from Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Mar 1, 2021 in Python by Rekha (2.2k points)
0 votes
1 answer
asked Dec 9, 2020 in Python by ashely (50.2k points)

Browse Categories

...