This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes compilation error..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compilation error....." Watch "compilation error....." New topic

compilation error.....

archana keerti

Joined: Feb 03, 2009
Posts: 20
hi ,
please anyone could help me...i have a problem in the compilation of the below given program.

public class puzz
public static void main(String args[])
dog[] d=new dog[6];
int x=0;
int y=1;
int result=0;

dog[x]=new dog[];
System.out.println("result is"+result)



class dog
int v;
public int do(int f)
return v*f;

return v*(5-f);

the required output for the program is 543345.

when i compile i get some error messages like,illegal start of type,<identifier>expected, ; expected.....
i couldn't find where i am wrong.....
Henry Wong

Joined: Sep 28, 2004
Posts: 20374

when i compile i get some error messages like,illegal start of type,<identifier>expected, ; expected.....
i couldn't find where i am wrong.....

Generally, with these types of error, it can occur at the line previously -- I would examine the line mentioned by the compiler (and the lines before).... It could be something as simple as a missing close brace or something.

And BTW, if you expect us to further help, it would be great to actually paste the actual compile error.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
Also please code tags as it makes your code much easier to read....

<a href="" target="_blank" rel="nofollow">Use Code Tags!!</a>
Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2846

One source of error is

there is no declaration of "X" at least not in the code you posted. And Java is case sensitive.

|Asking Good Questions|
Monu Tripathi

Joined: Oct 12, 2008
Posts: 1369

also, a semi colon on this line:

[List of FAQs] | [Android FAQ] | [Samuh Varta]
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
This line will throw a compile error too.

In addition, you cannot name a method "do" as its a reserved keyword(??)

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45338
Although it is very helpful and interesting to try guessing how many compiler errors this class will produce, it is really for the original poster to say how many errors they expect, and people replying to agree or disagree. Look at one of our FAQ. The original poster will learn a lot more that way.
I agree. Here's the link:
subject: compilation error.....
It's not a secret anymore!