-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayToHex.java
More file actions
36 lines (34 loc) · 1.1 KB
/
Copy pathArrayToHex.java
File metadata and controls
36 lines (34 loc) · 1.1 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
import java.util.Arrays;
public class ArrayToHex {
// This method loops through a loop and changes the numbers from 10-15 to their respective Hex value
static String[] StrArrToHex(String StrArray[]) {
for (int i=0; i < StrArray.length; i++) {
switch (StrArray[i]) {
case "10":
StrArray[i] = "A";
break;
case "11":
StrArray[i] = "B";
break;
case "12":
StrArray[i] = "C";
break;
case "13":
StrArray[i] = "D";
break;
case "14":
StrArray[i] = "E";
break;
case "15":
StrArray[i] = "F";
break;
}
}
return StrArray;
}
public static void main(String[] args) {
String[] ex1 = {"2", "5", "9", "8", "10", "11", "12", "13", "14", "15"};
StrArrToHex(ex1);
System.out.println(Arrays.toString(ex1));
}
}