Code in java show proper comments on each line of code show output on Eclipse co
ID: 3867901 • Letter: C
Question
Code in java show proper comments on each line of code
show output on Eclipse console
Explanation / Answer
package zasda;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;
import java.util.Set;
public class Details {
public void mapadd(int key , String value , HashMap hmap){
if (hmap.containsKey(key) || hmap.containsValue(value)){
hmap.put(key, value);
}
}
public static void main(String args[]) {
/* This is how to declare HashMap */
HashMap<Integer, String> hmap = new HashMap<Integer, String>();
/*Add key value pair to hash map*/
hmap.put(12, "Sims");// adding key and a value in hmap
hmap.put(15, "agha");// enter the respective value of key and object to store in hmap
hmap.get(12); // enter the key value of the object to be fetched
hmap.clear();// used to clear all the values in hmap
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.