Posted: 12/17/2011 11:24:50 AM EDT
|
Assuming your pulling the contents of an object from a hashmap key <Key, Object(s)>, the default while key.hasnext print keys.next prints like this:
[Object 1, Object 2] How can I get it to print like a list? : Object 1 Object 2 I've already got the program running perfect, I just can't figure out how to change from the default printout. I'm printing it something like Key \n Object \n Object \n Key \n Object etc. |
|
while(iterator.hasNext()){ System.out.println(iterator.next());} |
|
Quoted:
while(iterator.hasNext()){ System.out.println(iterator.next());} I'm using an iterator, the .next is what's printing [Object 1, Object 2] |
|
Quoted:
Java and "print"? Why not just handle the output yourself? I'm using an iterater to handle the output, I just can't seem to iterate the individual Objects inside of a key. I can properly display the keys, and their "group" of objects, I want to display the objects individually under the key. |
|
Quoted: Quoted: while(iterator.hasNext()){ System.out.println(iterator.next());} I'm using an iterator, the .next is what's printing [Object 1, Object 2] So each item in your hashmap is another set of some type? You will need to iterate the object set that is being returned in the first iteration then. ETA: Assuming your subset is also a hashmap.
|
|
Quoted:
Quoted:
Quoted:
while(iterator.hasNext()){ System.out.println(iterator.next());} I'm using an iterator, the .next is what's printing [Object 1, Object 2] So each item in your hashmap is another set of some type? You will need to iterate the object set that is being returned in the first iteration then. So iterate through without printing, and iterate the block of objects retrieved? ETA: I see your edit, I think that's what I wasn't getting. My subset isn't a hash, it's a hash for the key's and objects, and each set of objects is an ArrayList. |