How to remove all the values from HashMap in Java

1 Answer

0 votes
package javaapplication1;

import java.util.HashMap;

public class JavaApplication1 {

    public static void main(String[] args) {

        HashMap hMap = new HashMap();
   
        hMap.put("1", "Java");
        hMap.put("2", "C++");
        hMap.put("3", "C");
        hMap.put("4", "C#");
        hMap.put("5", "PHP");
        hMap.put("6", "JavaScript");
        
        hMap.clear();
        
        System.out.println(hMap);
  }
}
  
/*
run:

{}

*/

 



answered Sep 27, 2016 by avibootz

Related questions

1 answer 154 views
1 answer 119 views
119 views asked Mar 14, 2021 by avibootz
1 answer 151 views
151 views asked Sep 27, 2016 by avibootz
4 answers 225 views
2 answers 151 views
1 answer 129 views
1 answer 145 views
...