Results 1 to 7 of 7
  1. #1
    ff123 is offline Member
    Join Date
    Apr 2009
    Posts
    14
    Rep Power
    0

    Default illigel expression

    hey why im getting this

    Java Code:
    Calendar.java:11: illegal start of expression
       static String[] daysstr = new String[] {"\t|Sun","\t|Mon","\t|Tues","\t|Wed",
    "\t|Thurs","\t|Fri","\t|Sat"};
       ^
    1 error
    here is my code
    Java Code:
     static String[] daysstr = new String[] {"\t|Sun","\t|Mon","\t|Tues","\t|Wed","\t|Thurs","\t|Fri","\t|Sat"};

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    If this is inside a method, it can't be static.

    Edit: And, if it's not inside a method, then you haven't ended the previous line properly.

  3. #3
    ff123 is offline Member
    Join Date
    Apr 2009
    Posts
    14
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    If this is inside a method, it can't be static.

    Edit: And, if it's not inside a method, then you haven't ended the previous line properly.
    so what is solution.. should i remove static.. so it would be

    PHP Code:
    String[] Day_Str = new String {"\t|Sun","\t|Mon","\t|Tues","\t|Wed","\t|Thurs","\t|Fri","\t|Sat"};
    and will it print if i put
    Java Code:
    System.out.print(Day_Str);

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Just try it

    should i remove static
    Why not just try it and see what happens.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    ff123 is offline Member
    Join Date
    Apr 2009
    Posts
    14
    Rep Power
    0

    Default

    this is the output

    [Ljava.lang.String;@757aef

  6. #6
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    7

    Default

    You have an array of Strings and when you call println(Day_str) it prints out the array object not the data inside it. You need a loop from 0 to day_str.length()-1 and then println(day_str[xx])
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  7. #7
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Correction to xcallmejudasx's post: it should be from 0 to Day_Str.length - 1, or for(int i=0; i<Day_Str.length; i++). using Day_Str.length() would just throw exceptions because the length() method does not exist. You use a method to get the size of an ArrayList, and it is size() not length().
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

Similar Threads

  1. need help to make this regular expression
    By aruna1 in forum New To Java
    Replies: 1
    Last Post: 04-12-2009, 09:09 PM
  2. Quick reg. expression help
    By RR_QQ in forum New To Java
    Replies: 4
    Last Post: 02-10-2009, 08:51 PM
  3. illegal start of expression
    By razmyasdfg in forum CLDC and MIDP
    Replies: 2
    Last Post: 07-27-2008, 11:44 PM
  4. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 8
    Last Post: 11-02-2007, 10:11 PM
  5. Boolean Expression
    By ritwik07 in forum New To Java
    Replies: 3
    Last Post: 07-11-2007, 05:11 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
  •