-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArray.java
More file actions
41 lines (29 loc) · 1.04 KB
/
Array.java
File metadata and controls
41 lines (29 loc) · 1.04 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
package Online_Code_Samples.Week2;
import java.util.ArrayList;
import java.util.List;
public class Array {
//Let's write different arrays
static Integer[] intArray = new Integer[]{1, 3, 4, 5, 6};
static Double[] doubleArray = new Double[]{2.5, 5.5, 9.4, 50.0};
static String[] stringArray = {"Mike", "Pence", "Peace", "John"};
static Object[] objectArray = {new Dog("Rex", 3), 39, "Mike Pence", doubleArray[3], intArray};
List<String> strings = new ArrayList<String>();
public static void printArray(Object[] array) {
for (Object obj : array) {
System.out.println(obj);
}
System.out.println("=========================================");
}
// public T<? extends Number> T getMax(T a, T b){
// Object first = a;
// Object second = b;
// if( a > b)
// return (T)a;
// else return (T)b;
// }
public static void main(String[] args) {
printArray(intArray);
printArray(stringArray);
printArray(objectArray);
}
}