Skip to content

Commit c3355e6

Browse files
committed
Fixed null pointer issue
1 parent 29c8d12 commit c3355e6

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

SortingAlgorithm/Java/Utils/Convert.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static Byte[] toByteArray(byte[] a) {
3232

3333
private static final Byte[] toByteArray(byte[] a, int size) {
3434
if (a == null) {
35-
return null;
35+
throw new NullPointerException();
3636
} else if (size == 0) {
3737
return EMPTY_BYTE_OBJECT_ARRAY;
3838
}
@@ -66,7 +66,7 @@ public static Character[] toCharacterArray(char[] a) {
6666

6767
private static final Character[] toCharacterArray(char[] a, int size) {
6868
if (a == null) {
69-
return null;
69+
throw new NullPointerException();
7070
} else if (size == 0) {
7171
return EMPTY_CHAR_OBJECT_ARRAY;
7272
}
@@ -100,7 +100,7 @@ public static Short[] toShortArray(short[] a) {
100100

101101
private static final Short[] toShortArray(short[] a, int size) {
102102
if (a == null) {
103-
return null;
103+
throw new NullPointerException();
104104
} else if (size == 0) {
105105
return EMPTY_SHORT_OBJECT_ARRAY;
106106
}
@@ -134,7 +134,7 @@ public static Integer[] toIntegerArray(int[] a) {
134134

135135
private static final Integer[] toIntegerArray(int[] a, int size) {
136136
if (a == null) {
137-
return null;
137+
throw new NullPointerException();
138138
} else if (size == 0) {
139139
return EMPTY_INT_OBJECT_ARRAY;
140140
}
@@ -164,7 +164,7 @@ public static Long[] toLongArray(long[] a) {
164164

165165
private static final Long[] toLongArray(long[] a, int size) {
166166
if (a == null) {
167-
return null;
167+
throw new NullPointerException();
168168
} else if (size == 0) {
169169
return EMPTY_LONG_OBJECT_ARRAY;
170170
}
@@ -194,7 +194,7 @@ public static Float[] toFloatArray(float[] a) {
194194

195195
private static final Float[] toFloatArray(float[] a, int size) {
196196
if (a == null) {
197-
return null;
197+
throw new NullPointerException();
198198
} else if (size == 0) {
199199
return EMPTY_FLOAT_OBJECT_ARRAY;
200200
}
@@ -228,7 +228,7 @@ public static Double[] toDoubleArray(double[] a) {
228228

229229
private static final Double[] toDoubleArray(double[] a, int size) {
230230
if (a == null) {
231-
return null;
231+
throw new NullPointerException();
232232
} else if (size == 0) {
233233
return EMPTY_DOUBLE_OBJECT_ARRAY;
234234
}

0 commit comments

Comments
 (0)