-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.java
39 lines (31 loc) · 959 Bytes
/
Example.java
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
class Example<T > {
T ob;
T vals[];
Example(T o, T[] nums) {
ob = o;
vals = nums;
System.out.println("o = " + o);
for (T x : nums) {
System.out.print(x + " ");
}
for (int i=0; i<nums.length; i++){
System.out.print("nums=" + nums[i] + " ");
}
}
public void print(){
System.out.println("Example");
}
public static void main(String[]args){
Integer n[] = {1,2,3,4,5};
String s[] = {"one", "two", "three", "four", "five"};
Double d[] = {1.1, 2.2, 3.3, 4.4, 5.5};
Example<Integer> iob = new Example<Integer>(50, n);
Example<?>[] e = new Example<?>[10];
e[0] = new Example<String>("50", s);
e[1] = new Example<Integer>(50, n);
e[2] = new Example<Double>(50.99, d);
e[0].print();
e[1].print();
e[2].print();
}
}