• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lists  RSS feed

 
p hasini
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a method

List getList(List l)
{

}

what code goes in side this method such that the method should return a sorted list.

For example if there is [0,0,1,1,2,2] .The output must be [0,1,2]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As stated in your other posts, JavaRanch is not a code mill. Please read this for more information.

Take a stab at the code and we discuss whether it works or not.
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please make the method name match its function. What you are doing is not sorting a List, but converting it to a sorted set.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!