File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Illegal start of expression compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Illegal start of expression compilation error" Watch "Illegal start of expression compilation error" New topic
Author

Illegal start of expression compilation error

Divyya Joshi
Ranch Hand

Joined: Jul 15, 2010
Posts: 102
When i tried to compile this compiler complained "Illegal start of expression" and points out it somewhere near compareTo().
Here's the code


Here i am not able to find out error. Kindly anyone correct this code.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

You cannot create a method inside another method. The compareTo method is right now inside the main method. If you indent your code you'll be able to see the problem...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Divyya Joshi
Ranch Hand

Joined: Jul 15, 2010
Posts: 102
Ankit i did what you said. Its still giving 3 errors . Please you correct it.

Abhinav Shukla
Greenhorn

Joined: Jul 18, 2011
Posts: 13

1. Change Comparable to Comparable<Dog>

2. Change 'FirstGrade' to 'Dog' at line 9 in your code.

3. Change 'int size' to 'Integer size' as you cant use compareTo with primitives



Output : 2 2
Divyya Joshi
Ranch Hand

Joined: Jul 15, 2010
Posts: 102
Thanks a lot Abhinav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Illegal start of expression compilation error