-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrinter.java
More file actions
38 lines (36 loc) · 1.05 KB
/
Printer.java
File metadata and controls
38 lines (36 loc) · 1.05 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
package leetcode.common;
/**
* Created by zhangbo54 on 2019-07-19.
*/
public class Printer {
public static void printArrays(int[] arrays) {
if (arrays == null) {
System.out.println("[]");
return;
}
System.out.print("[");
for (int i = 0; i < arrays.length - 1; i++) {
System.out.print(arrays[i] + ",");
}
System.out.print(arrays[arrays.length - 1] + "]");
System.out.println();
}
public static void printArrays(int[][] arrays) {
if (arrays == null) {
System.out.println("[]");
return;
}
System.out.print("[\n");
for (int i = 0; i < arrays.length; i++) {
System.out.print("\t[");
for (int j = 0; j < arrays[0].length; j++) {
System.out.print(arrays[i][j]);
if (j != arrays[0].length - 1) {
System.out.print(",");
}
}
System.out.println("]");
}
System.out.println("]");
}
}