-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFront11.java
35 lines (26 loc) · 966 Bytes
/
Front11.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
package Array01;
import java.util.Arrays;
public class Front11 {
public static int[] front11(int[] a, int[] b) {
if (a.length > 0 && b.length == 0) {
return new int[]{a[0]};
}
if (b.length > 0 && a.length == 0) {
return new int[]{b[0]};
}
if (a.length > 0 && b.length > 0) {
return new int[]{a[0], b[0]};
} else
return new int[]{};
}
// public static int[] returnNotEmpty(int[] a, int[] b) {
// if (a.length==0) return b;
// return a;
// }
public static void main(String[] args) {
System.out.println(Arrays.toString(front11(new int[]{1, 2}, new int[]{3})));
System.out.println(Arrays.toString(front11(new int[]{1, 2}, new int[]{})));
System.out.println(Arrays.toString(front11(new int[]{}, new int[]{2})));
// System.out.println(Arrays.toString(returnNotEmpty(new int[]{}, new int[]{1})));
}
}