Course
JavaScript Tutorial for Beginners: Learn Javascript in 5 Days
Javascript Training Summary JavaScript is an open source & most popular client side scripting...
HashMap<String, Object> map = new HashMap<String, Object>(); HashMap x = new HashMap();
Important Hashmap Methods
import java.util.HashMap; import java.util.Map; public class Sample_TestMaps{ public static void main(String[] args){ Map<String, String> objMap = new HashMap<String, String>(); objMap.put("Name", "Suzuki"); objMap.put("Power", "220"); objMap.put("Type", "2-wheeler"); objMap.put("Price", "85000"); System.out.println("Elements of the Map:"); System.out.println(objMap); } }
Output:
Elements of the Map: {Type=2-wheeler, Price=85000, Power=220, Name=Suzuki}
import java.util.*; public class HashMapExample { public static void main(String args[]) { // create and populate hash map HashMap<Integer, String> map = new HashMap<Integer, String>(); map.put(1,"Java"); map.put(2, "Python"); map.put(3, "PHP"); map.put(4, "SQL"); map.put(5, "C++"); System.out.println("Tutorial in Guru99: "+ map); // Remove value of key 5 map.remove(5); System.out.println("Tutorial in Guru99 After Remove: "+ map); } }
Output:
Tutorial in Guru99: {1=Java, 2=Python, 3=PHP, 4=SQL, 5=C++} Tutorial in Guru99 After Remove: {1=Java, 2=Python, 3=PHP, 4=SQL}
Javascript Training Summary JavaScript is an open source & most popular client side scripting...
What is DOM in JavaScript? JavaScript can access all the elements in a webpage making use of...
What is Interface in Java? An Interface in Java programming is defined as an abstract type used to...
JavaScript also abbreviated as JS, is a high level server side programming language. JavaScript is...
What is Bubble Sort? Bubble sort is a simple algorithm which compares the first element of the...
What is a Variable in Java? Variable in Java is a data container that stores the data values...