• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get distinct names from a table  RSS feed

 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table shich contain name of persons.I need to get the distinct names of the table.How can i do this?below is the example os table

Monday Tuesday Wednesday Thursday Friday
Tom Jhon Tom ULF Steve
William Nazee Jim Steve Sam
Sam ULF Steve ULF Tom
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a Collection which does not allow duplicates. Iterate all the element in the table and add them to the Collection. The Collection would then have only unique names. See http://docs.oracle.com/javase/tutorial/collections/ and the API for the known subinterfaces of Collection (http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html) to pick which Collection might be best to use.
 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thaks Steve.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!