Results 1 to 3 of 3
  1. #1
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default Illegal start of expression

    I try to execute this code
    Java Code:
    
    
    public class HelloWorld{
    	public static void main(String[] args) {
           
    	 public void text(){
    	      sh.text("hello");
    	 }
    		
    	}
    }
    And it gives me an error saying
    Java Code:
     Illegal start of expression 
    at
     public void text(){
    	      sh.text("hello");
    any ideas?

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    You have defined the text() method inside of the main method. I would also recommend using a consistent style. Your errors will be easier to see if you do.

    For example here is your code but formated differently
    Java Code:
    public class HelloWorld
       {
       public static void main(String[] args) 
          {
          public void text()
             {
             sh.text("hello");
             }
          }
       }
    Now it is easier to see that text() is inside main.

  3. #3
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

Similar Threads

  1. illegal character: \65279
    By iwax in forum New To Java
    Replies: 3
    Last Post: 01-30-2008, 02:52 PM
  2. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 8
    Last Post: 11-02-2007, 09:11 PM
  3. Replies: 9
    Last Post: 08-08-2007, 07:16 PM
  4. Boolean Expression
    By ritwik07 in forum New To Java
    Replies: 3
    Last Post: 07-11-2007, 04:11 AM
  5. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 0
    Last Post: 04-20-2007, 05:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •