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 253 views
1 answer 218 views
218 views asked Mar 14, 2021 by avibootz
1 answer 237 views
237 views asked Sep 27, 2016 by avibootz
4 answers 433 views
2 answers 278 views
1 answer 226 views
1 answer 245 views
...