• Post Reply Bookmark Topic Watch Topic
  • New Topic

Illegal Start of Expression  RSS feed

 
John Abraham Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was tring to take some strings and print the longest one.
But I am getting an error of "Illegal Start of Expression" on the following code:

any idea?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Abraham Smith wrote:Hi,
I was tring to take some strings and print the longest one.
But I am getting an error of "Illegal Start of Expression" on the following code:

any idea?



Java doesn't allow you to declare a method, directly within another method.

Henry
 
John Abraham Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot.
i just started coding in java...haven't coded much either....thats why.....
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

There are two compiler errors which can be similarly confusing. They are “illegal start . . . ” and “class interface or enum expected” away from the beginning of a file. Both are usually caused by un-balanced {} braces.
 
D. Wang
Greenhorn
Posts: 3
Eclipse IDE Java Windows Vista
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just call getMaxValue(int[] numbers) from main():

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!