A) HASHMAP
Write a program using hashmap and store the student data , key is roll no 1,2,3, etc and value is name of student a,b,c and access the name of roll -no = 2 .
import java.util.HashMap;
public class basichashmap {
public static void main(String[ ] args) {
HashMap<Integer, String> student = new HashMap<Integer,String >();
student.put(1, "a");
student.put(2, "b");
student.put(3, "c");
System.out.println(student.get(2));
}
}
OUTPUT:
b
No comments:
Post a Comment