Java Tutorials
What is Garbage Collection in Java?
What is Garbage Collection in Java? Garbage Collection in Java is a process by which the programs...
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 gtupapers: "+ map);
// Remove value of key 5
map.remove(5);
System.out.println("Tutorial in gtupapers After Remove: "+ map);
}
}
Output:
Tutorial in gtupapers: {1=Java, 2=Python, 3=PHP, 4=SQL, 5=C++}
Tutorial in gtupapers After Remove: {1=Java, 2=Python, 3=PHP, 4=SQL}
What is Garbage Collection in Java? Garbage Collection in Java is a process by which the programs...
Here are Java Collections Interview Questions for fresher as well as experienced candidates to get...
What is Abstraction in Java? Abstraction in JAVA shows only the essential attributes and hides...
What is split() string in Java? StrSplit() method allows you to break a string based on specific...
What is Exception in Java? Exception in Java is an event that interrupts the execution of program...
JavaScript is the most popular client-side scripting language supported by all browsers. It is...