例如,如果在命令行中将字符串作为参数输入(不使用扫描仪),您如何从字符串转换为字符。例如,您将如何转换"abcd"
为 char?
String input = args[0]
String [] part = input.split("");
//splits string into 2 parts (action and characters to encode)
String action = part[0];
// action is what is done to letter i.e. decrypt or encrypt
String plainText = part[1];
char [] letters = plainText.toCharArray();