-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample13.java
More file actions
53 lines (48 loc) · 1.2 KB
/
sample13.java
File metadata and controls
53 lines (48 loc) · 1.2 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Iterator;
public class sample13 {
public static void check(Character c)
{
do{
System.out.println("Enter id");
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
System.out.println("Enter value");
String s=scanner.nextLine();
if(s.length()>5 )
{
create(n,s);
}
}
while( c=='y');
}
public static void create(int p,String q)
{
HashMap hmp=new HashMap<>();
hmp.put(p, q);
Set s=hmp.keySet();
Iterator itr=s.iterator();
while(itr.hasNext())
{
Object o=itr.next();
System.out.println(o + " " + hmp.get(o));
}
System.out.println("Do you want to continue (y/n)");
Scanner scanner=new Scanner(System.in);
char chr=scanner.next().charAt(0);
if(chr == 'y')
{
check('y');
}
else
{
System.exit(0);
}
}
public static void main(String[] args)
{
check('y');
}
}