I am relatively new in Java, and attempting to convert user inputs into Hexidecimal. Currently I am attempting to convert it first to Bytes, however I am getting errors regarding one line, Byte getByte = Byte.parseByte(getCharacter);
The overall code can be seen below,
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
Scanner scanner = new Scanner(System.in);
String name = scanner.next();
String binary = "", hexidecimal = "";
ArrayList<Character> chars = new ArrayList<>();
for(char c : name.toCharArray()) chars.add(c);
for(char c : chars) {
try {
String getCharacter = Character.toString(c);
Byte getByte = Byte.parseByte(getCharacter);
String stringByte = Byte.toString(getByte);
binary.concat(stringByte);
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
System.out.println(binary);
}
}
I have seen answers however I do not understand how to incorporate stuff like char a = '\uffff'
into my program.