Code: Alles auswählen
String hex = "12";
char[] hexer = hex.toCharArray();
for (int i = 0; i < hexer.length; i++) {
switch (String.valueOf(hexer[i])) {
case "1":
hexer[i] = 1;
break;
case "2":
hexer[i] = 2;
break;
case "3":
hexer[i] = 3;
break;
case "4":
hexer[i] = 4;
break;
case "5":
hexer[i] = 5;
break;
case "6":
hexer[i] = 6;
break;
case "7":
hexer[i] = 7;
break;
case "8":
hexer[i] = 8;
break;
case "9":
hexer[i] = 9;
break;
case "A":
hexer[i] = 10;
break;
case "B":
hexer[i] = 11;
break;
case "C":
hexer[i] = 12;
break;
case "D":
hexer[i] = 13;
break;
case "E":
hexer[i] = 14;
break;
case "F":
hexer[i] = 15;
break;
}
}
for (int i = 0; i < hexer.length; i++) {
System.out.print(hexer[i]);
}
Einer eine Idee was da schief gehen könnte? Normalerweise sollte er ja 12 ausgeben?