Error in code: <identifier>expected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gnapika
    New Member
    • Dec 2012
    • 1

    Error in code: <identifier>expected

    Code:
    public class HelloWorldBean implements HelloWorld 
    {
    	public void sayHello(String name); 
    			System.out.println("Hello, World");
    }
    This is the code i want to execute but it is showing an error like <identifier>exp ected..
    Last edited by Meetee; Dec 20 '12, 12:07 PM. Reason: Use code tags <code/> around your code
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You need to specify where the function begins and ends with curly brackets.
    Code:
    public class HelloWorldBean implements HelloWorld  
    { 
        public void sayHello(String name)
       { 
                System.out.println("Hello, World");
        }
    }

    Comment

    • VanessaMeacham
      New Member
      • Sep 2012
      • 31

      #3
      Hi! you have to start and close the curly brackets from where your function starts and you put a semicolon after function which is not allowed.
      Code:
          public class HelloWorldBean implements HelloWorld  
          { 
              public void sayHello(String name)
             { 
                      System.out.println("Hello, World");
              }
          }
      Last edited by Meetee; Dec 21 '12, 11:15 AM. Reason: Use code tags <code/> around your code

      Comment

      Working...