• Post Reply Bookmark Topic Watch Topic
  • New Topic

why collection.sort gives compiler error?  RSS feed

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my code


but it gives error in line Collections.sort(stuff);.
why it gives error?
 
Misha Ver
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samanthi perera wrote:but it gives error in line Collections.sort(stuff);
why it gives error?


Have you check http://faq.javaranch.com/java/TellTheDetails ? If you provide the error message, it would be easier to answer your questions.
The method sort is undefined in your code. Do you really want to overwrite Collections class in java.util by naming your public class - Collections?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the screenshot
aaaaaaaaa.GIF
[Thumbnail for aaaaaaaaa.GIF]
here is the screenshot
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Screenshots are not a good way to convey the error. Plain text works best.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compiler is getting confused between the java.util.Collections and your class which is also called Collections.

1)Rename your class to MyCollections or something else (recommended)
2)Change the line Collections.sort(... to java.util.Collections.sort(...
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.now it is working
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!