Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-Any help will be greatly appreciated! Thanks \"Finally, I\'d like to introduce

ID: 3819727 • Letter: #

Question

-Any help will be greatly appreciated!
Thanks

"Finally, I'd like to introduce you to the Java Collections Framework. This is a set of classes that implement various data structures. To generate the following output showing local colleges and the year they were founded: schools (Emmanuel 1919. Northeastern 1898,Wentworth 1904) keys [Emmanuel, Northeastern, Wentworth] values [1919, 1898, 1904] with the schools added in this order: Wentworth, Emmanuel, Northeastern, we could use the following code:

Explanation / Answer


CODE:

package temp;

import java.util.*;
import java.util.Map.Entry;

class MapCollection{
public static void main(String args[]){
HashMap<String,Integer> schools = new HashMap<String,Integer>();
schools.put("Emmanuel",1919);
schools.put("Northeastern",1898);
schools.put("Wentworth",1904);
  
System.out.println("Schools");
System.out.print("{");
for(Map.Entry m:schools.entrySet()){
   System.out.print(m.getKey()+"="+m.getValue()+ " ");
  
}
System.out.print("}");
  
System.out.println(" keys");
System.out.print("[");
for(Map.Entry m:schools.entrySet()){
   System.out.print(m.getKey() + " ");
}
System.out.print("]");
  
System.out.println(" values");
System.out.print("[");
for(Map.Entry m:schools.entrySet()){
   System.out.print(m.getValue()+ " ");
}
System.out.print("]");
}
}

OUTPUT:

Schools
{Wentworth=1904 Emmanuel=1919 Northeastern=1898 }

keys
[Wentworth Emmanuel Northeastern ]

values
[1904 1919 1898 ]