Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Illegal start of expression compilation error

 
Divyya Joshi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Divyya Joshi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit i did what you said. Its still giving 3 errors . Please you correct it.

 
Abhinav Shukla
Greenhorn
Posts: 13
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Abhinav
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic