aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Map Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Map" Watch "Map" New topic
Author

Map

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
What is the output of the following program?
import java.util.*;
class Question {
public static void main(String[] args) {
TreeMap map = new TreeMap();
map.put("one","1");
map.put("two","2");
map.put("three","3");
display(map);
}
static void display(TreeMap map) {
Collection c = map.entrySet();
Iterator i = c.iterator();
while(i.hasNext()) {
Object o = i.next();
System.out.print(o.toString());
}
}
}
A)123
B)onetwothree
C)one=1three=3two=2
when i run i get c as the answer
but I did'nt understand how it came ..explain please
ravee
Greenhorn

Joined: Feb 18, 2000
Posts: 19
the TreeMap holds elements sorted.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Map
 
Similar Threads
HashMap remove multiple elements
Collection problem
Mock Exam Questions?Please anybody explain.
Splitting a Map
How can I Iterate a map