-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp2.java
More file actions
36 lines (32 loc) · 986 Bytes
/
Copy pathexp2.java
File metadata and controls
36 lines (32 loc) · 986 Bytes
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
package EmpCollection;
import java.util.*;
public class exp2 {
public static void main(String[] args){
HashMap h2=new HashMap();
for(int i=0;i<10;i++)
h2.put(new Element(i), new Figureout());
System.out.println("h2:");
System.out.println("Get the result for Element:");
Element test=new Element(5);
if(h2.containsKey(test))
System.out.println((Figureout)h2.get(test));
else
System.out.println("Not found");
}
}
class Element{
int number;
public Element(int n){
number=n;
}
}
class Figureout{
Random r=new Random();
boolean possible=r.nextDouble()>0.5;
public String toString(){
if(possible)
return "OK!";
else
return "Impossible!";
}
}