aspose file tools
The moose likes Beginning Java and the fly likes Illegal Start of Expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Illegal Start of Expression" Watch "Illegal Start of Expression" New topic
Author

Illegal Start of Expression

AnujS Sharma
Greenhorn

Joined: Jul 30, 2011
Posts: 15
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

Joined: Oct 02, 2003
Posts: 11814
    
  18

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
AnujS Sharma
Greenhorn

Joined: Jul 30, 2011
Posts: 15
I don't think so.

Here is the full code.


Rameshwar Soni
Ranch Hand

Joined: Feb 03, 2011
Posts: 247
According to me instead of this try this
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20046
    
  30

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43321
    
  32
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

Joined: Jul 30, 2011
Posts: 15
Thanks for all the help. Learnt something today.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43321
    
  32
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Illegal Start of Expression
 
It's not a secret anymore!