-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample14.java
More file actions
34 lines (31 loc) · 1.22 KB
/
sample14.java
File metadata and controls
34 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
public class sample14 {
public static HashMap getData(ArrayList<Integer> sno,ArrayList<String> sname,ArrayList<String> scity)
{
HashMap hm=new HashMap<>();
System.out.println("enter City name");
Scanner scanner=new Scanner(System.in);
String cityName=scanner.nextLine();
for(int i=0;i<scity.size();i++)
{
if(scity.get(i).equals(cityName))
{
hm.put(sno.get(i),sname.get(i));
}
}
return hm;
}
public static void main(String[] args)
{
ArrayList<Integer> sno=new ArrayList<Integer>();
ArrayList<String> sname=new ArrayList<String>();
ArrayList<String> scity=new ArrayList<String>();
sno.add(101);sno.add(102);sno.add(103);sno.add(104);sno.add(105);sno.add(106);
sname.add("ram");sname.add("sam");sname.add("sai");sname.add("thomas");sname.add("jack");sname.add("feroz");
scity.add("hyd");scity.add("pune");scity.add("pune");scity.add("ban");scity.add("hyd");scity.add("hyd");
HashMap hmp = getData(sno, sname, scity);
System.out.println(hmp);
}
}