- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.java
More file actions
Latest commit
39 lines (31 loc) · 959 Bytes
/
Copy pathExample.java
File metadata and controls
39 lines (31 loc) · 959 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
37
38
39
classExample<T > {
Tob;
Tvals[];
Example(To, T[] nums) {
ob = o;
vals = nums;
System.out.println("o = " + o);
for (Tx : nums) {
System.out.print(x + " ");
}
for (inti=0; i<nums.length; i++){
System.out.print("nums=" + nums[i] + " ");
}
}
publicvoidprint(){
System.out.println("Example");
}
publicstaticvoidmain(String[]args){
Integern[] = {1,2,3,4,5};
Strings[] = {"one", "two", "three", "four", "five"};
Doubled[] = {1.1, 2.2, 3.3, 4.4, 5.5};
Example<Integer> iob = newExample<Integer>(50, n);
Example<?>[] e = newExample<?>[10];
e[0] = newExample<String>("50", s);
e[1] = newExample<Integer>(50, n);
e[2] = newExample<Double>(50.99, d);
e[0].print();
e[1].print();
e[2].print();
}
}