• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Illegal Start of Expression

 
AnujS Sharma
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting an error "Illegal Start of Expression" on the following code:



Here, NoOfJumps is a method defined in a class which does not have the main method. This method accepts 4 arguments namely

1)Integer
2)Integer
3)Integer
4)Integer Array


Can someone please explain why this error is coming up and what is the resolution for this?



Thanks
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look at the previous line, and make sure it is ended correctly. Also, make sure your brackets are all correct. sometimes you are missing one, and the parser gets all confused.
 
AnujS Sharma
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so.

Here is the full code.


 
Rameshwar Soni
Ranch Hand
Posts: 247
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me instead of this try this
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rameshwar is right. You can use the short {} initialization only directly when declaring: You can't use it when calling a method, and not even when giving an existing array variable a new value.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the ellipsis operator allows you to change the array parameter to varargs, then you can write 1, 2, 3 rather than {1, 2, 3}.
 
AnujS Sharma
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the help. Learnt something today.

 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic