It says <identifeier> expected for the public void greet (HelloWorld)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • java101
    New Member
    • Sep 2015
    • 1

    It says <identifeier> expected for the public void greet (HelloWorld)

    Code:
    public class HelloWorld
    {
        private String greeting= "Hello World!";
        
        public void greet (HelloWorld)//you create a String variable
        
        {
            System.out.println("My name is Gabi Watson");//This is what was passed to the method. You should also add your greeting here. 
            
        }
        public static void main(String args[])
        {
            HelloGabi greetMe= new HelloGabi () ;
            greetMe.greet("I attend High School");
        }
    }
    Last edited by Rabbit; Sep 30 '15, 04:49 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Hello Gabi Watson,
    the error message says, that a method parameter must be declared with type (=identifier) and name, but you only give name (="HelloWorld ") here.
    So change "public void greet (HelloWorld)" to "public void greet (String helloWorld)"

    Comment

    Working...