Click here to Skip to main content
15,896,207 members
Home / Discussions / Java
   

Java

 
AnswerRe: Printing the contents of a collection Pin
Cedric Moonen4-Dec-10 22:43
Cedric Moonen4-Dec-10 22:43 
GeneralRe: Printing the contents of a collection Pin
SWDevil4-Dec-10 22:58
SWDevil4-Dec-10 22:58 
GeneralRe: Printing the contents of a collection Pin
Cedric Moonen4-Dec-10 23:21
Cedric Moonen4-Dec-10 23:21 
GeneralRe: Printing the contents of a collection Pin
SWDevil4-Dec-10 23:31
SWDevil4-Dec-10 23:31 
GeneralRe: Printing the contents of a collection Pin
Cedric Moonen4-Dec-10 23:56
Cedric Moonen4-Dec-10 23:56 
GeneralRe: Printing the contents of a collection Pin
SWDevil5-Dec-10 0:41
SWDevil5-Dec-10 0:41 
GeneralRe: Printing the contents of a collection Pin
Cedric Moonen5-Dec-10 1:38
Cedric Moonen5-Dec-10 1:38 
AnswerRe: Printing the contents of a collection Pin
David Skelly6-Dec-10 2:09
David Skelly6-Dec-10 2:09 
It's a bit difficult to answer this without knowing what type of Collection you have. Collection is just an interface that can be implemented by any class which can act as a collection of other objects.

If it is a List then you can iterate over the contents of the list and print each in turn (using the enhanced for loop syntax is easiest).

The same is true for a Set.

If it is a Map then the contents of the collection will have two parts: a key and a value, so how you print it will depend on what you want to see (keys, values, or both).

There are other more obscure types of Collection like BeanContextServices or JobStateReasons and I have no idea what they contain so you would need to read the documentation on those.

Some implementations of Collection have an overridden toString() method that lets you see the contents, but not all do.

The simplest thing to do is to call iterator() on the collection and then just loop over that and print whatever it contains. That may be more or less useful depending on what type of collection you have and what is inside it.
AnswerRe: Printing the contents of a collection Pin
Alok Sharma ji7-Dec-10 1:32
Alok Sharma ji7-Dec-10 1:32 
AnswerRe: Printing the contents of a collection Pin
Ramaiah Raj30-Jan-11 20:30
Ramaiah Raj30-Jan-11 20:30 
Questionintegrating a Map and GIS in a java path finding simulator Pin
amit ofer3-Dec-10 21:11
amit ofer3-Dec-10 21:11 
AnswerRe: integrating a Map and GIS in a java path finding simulator Pin
Skynet_Code5-Dec-10 20:48
Skynet_Code5-Dec-10 20:48 
GeneralRe: integrating a Map and GIS in a java path finding simulator Pin
amit ofer5-Dec-10 21:27
amit ofer5-Dec-10 21:27 
GeneralRe: integrating a Map and GIS in a java path finding simulator Pin
Skynet_Code6-Dec-10 0:08
Skynet_Code6-Dec-10 0:08 
Questionhow toinput into array from keyboard Pin
atoivan3-Dec-10 16:15
atoivan3-Dec-10 16:15 
AnswerRe: how toinput into array from keyboard Pin
Dr.Walt Fair, PE3-Dec-10 16:35
professionalDr.Walt Fair, PE3-Dec-10 16:35 
QuestionProfile visits using FB api Pin
nachiket dave2-Dec-10 1:06
nachiket dave2-Dec-10 1:06 
AnswerRe: Profile visits using FB api Pin
Nagy Vilmos2-Dec-10 1:10
professionalNagy Vilmos2-Dec-10 1:10 
GeneralRe: Profile visits using FB api Pin
TorstenH.2-Dec-10 2:39
TorstenH.2-Dec-10 2:39 
Questionhow to write this code Pin
atoivan2-Dec-10 0:28
atoivan2-Dec-10 0:28 
AnswerRe: how to write this code Pin
Nagy Vilmos2-Dec-10 0:37
professionalNagy Vilmos2-Dec-10 0:37 
AnswerRe: how to write this code Pin
TorstenH.2-Dec-10 2:44
TorstenH.2-Dec-10 2:44 
AnswerRe: how to write this code Pin
CodingLover2-Dec-10 23:43
CodingLover2-Dec-10 23:43 
QuestionRe: how to write this code Pin
atoivan3-Dec-10 15:44
atoivan3-Dec-10 15:44 
AnswerRe: how to write this code Pin
TorstenH.5-Dec-10 20:52
TorstenH.5-Dec-10 20:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.